Fix Postmark mail transport by using core mailer_dsn config
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 <noreply@anthropic.com>
This commit is contained in:
parent
9193e54e87
commit
bc8559a3c7
2 changed files with 19 additions and 20 deletions
|
|
@ -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."
|
echo "[entrypoint] Core modules enabled." || echo "[entrypoint] WARNING: core modules failed."
|
||||||
$DRUSH en -y webform webform_ui && \
|
$DRUSH en -y webform webform_ui && \
|
||||||
echo "[entrypoint] Webform enabled." || echo "[entrypoint] WARNING: webform failed."
|
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."
|
echo "[entrypoint] Mailer enabled." || echo "[entrypoint] WARNING: symfony_mailer failed."
|
||||||
|
|
||||||
if [ -n "${POSTMARK_API_KEY:-}" ]; then
|
# Mail transport is configured via $config['system.mail']['mailer_dsn'] in settings.php,
|
||||||
$DRUSH php:eval "
|
# which is read directly by Drupal core's symfony_mailer mail plugin.
|
||||||
\$storage = \Drupal::entityTypeManager()->getStorage('mailer_transport');
|
# Do NOT use the mailer_transport module's entity system for this — it is only a UI layer
|
||||||
if (!\$storage->load('postmark')) {
|
# and is not consulted by core when actually sending mail.
|
||||||
\$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
|
|
||||||
$DRUSH en -y riverside_pt && \
|
$DRUSH en -y riverside_pt && \
|
||||||
echo "[entrypoint] riverside_pt enabled." || echo "[entrypoint] WARNING: riverside_pt failed."
|
echo "[entrypoint] riverside_pt enabled." || echo "[entrypoint] WARNING: riverside_pt failed."
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,23 @@ $settings['hash_salt'] = getenv('HASH_SALT') ?: 'replace-this-in-production';
|
||||||
$settings['update_free_access'] = FALSE;
|
$settings['update_free_access'] = FALSE;
|
||||||
|
|
||||||
$is_dev = (bool) getenv('DEBUG');
|
$is_dev = (bool) getenv('DEBUG');
|
||||||
|
$postmark_key = getenv('POSTMARK_API_KEY');
|
||||||
|
|
||||||
if ($is_dev) {
|
if ($is_dev) {
|
||||||
$config['system.mail']['interface']['default'] = 'php_mail';
|
$config['system.mail']['interface']['default'] = 'php_mail';
|
||||||
} elseif (!getenv('POSTMARK_API_KEY')) {
|
} else {
|
||||||
|
if (!$postmark_key) {
|
||||||
throw new \RuntimeException('POSTMARK_API_KEY is not set — refusing to start without a mail transport.');
|
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.
|
// Disable CSS/JS aggregation — assets served directly from source paths.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue