From bc8559a3c714d184dc1d4df3c37973beb2150856 Mon Sep 17 00:00:00 2001 From: Philip Peterson <1326208+philip-peterson@users.noreply.github.com> Date: Fri, 5 Jun 2026 00:37:56 -0700 Subject: [PATCH] Fix Postmark mail transport by using core mailer_dsn config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Drupal core's symfony_mailer plugin reads system.mail.mailer_dsn directly from settings.php — the mailer_transport module entity system is only a UI layer and is not consulted when actually sending mail. Removed the mailer_transport entity setup from the entrypoint and configured the DSN correctly via $config overrides in settings.php instead. Co-Authored-By: Claude Sonnet 4.6 --- docker/php/entrypoint.sh | 23 +++++------------------ web/sites/default/settings.php | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/docker/php/entrypoint.sh b/docker/php/entrypoint.sh index 72b26bc..e63a6ed 100644 --- a/docker/php/entrypoint.sh +++ b/docker/php/entrypoint.sh @@ -56,26 +56,13 @@ $DRUSH en -y views views_ui field_ui text options link datetime && \ echo "[entrypoint] Core modules enabled." || echo "[entrypoint] WARNING: core modules failed." $DRUSH en -y webform webform_ui && \ echo "[entrypoint] Webform enabled." || echo "[entrypoint] WARNING: webform failed." -$DRUSH en -y symfony_mailer mailer_transport && \ +$DRUSH en -y symfony_mailer && \ echo "[entrypoint] Mailer enabled." || echo "[entrypoint] WARNING: symfony_mailer failed." -if [ -n "${POSTMARK_API_KEY:-}" ]; then - $DRUSH php:eval " - \$storage = \Drupal::entityTypeManager()->getStorage('mailer_transport'); - if (!\$storage->load('postmark')) { - \$storage->create([ - 'id' => 'postmark', - 'label' => 'Postmark', - 'plugin' => 'dsn', - 'configuration' => ['dsn' => 'postmark+api://' . getenv('POSTMARK_API_KEY') . '@default'], - ])->save(); - } - \Drupal::configFactory()->getEditable('mailer_transport.settings') - ->set('default_transport', 'postmark')->save(); - \Drupal::configFactory()->getEditable('system.mail') - ->set('interface.default', 'symfony_mailer')->save(); - " && echo "[entrypoint] Postmark transport configured." || { echo "[entrypoint] FATAL: Postmark transport setup failed."; exit 1; } -fi +# Mail transport is configured via $config['system.mail']['mailer_dsn'] in settings.php, +# which is read directly by Drupal core's symfony_mailer mail plugin. +# Do NOT use the mailer_transport module's entity system for this — it is only a UI layer +# and is not consulted by core when actually sending mail. $DRUSH en -y riverside_pt && \ echo "[entrypoint] riverside_pt enabled." || echo "[entrypoint] WARNING: riverside_pt failed." diff --git a/web/sites/default/settings.php b/web/sites/default/settings.php index e7084dc..1a889bf 100644 --- a/web/sites/default/settings.php +++ b/web/sites/default/settings.php @@ -20,11 +20,23 @@ $settings['hash_salt'] = getenv('HASH_SALT') ?: 'replace-this-in-production'; $settings['update_free_access'] = FALSE; $is_dev = (bool) getenv('DEBUG'); +$postmark_key = getenv('POSTMARK_API_KEY'); if ($is_dev) { $config['system.mail']['interface']['default'] = 'php_mail'; -} elseif (!getenv('POSTMARK_API_KEY')) { - throw new \RuntimeException('POSTMARK_API_KEY is not set — refusing to start without a mail transport.'); +} else { + if (!$postmark_key) { + throw new \RuntimeException('POSTMARK_API_KEY is not set — refusing to start without a mail transport.'); + } + $config['system.mail']['interface']['default'] = 'symfony_mailer'; + $config['system.mail']['mailer_dsn'] = [ + 'scheme' => 'postmark+api', + 'host' => 'default', + 'user' => $postmark_key, + 'password' => NULL, + 'port' => NULL, + 'options' => [], + ]; } // Disable CSS/JS aggregation — assets served directly from source paths.