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.