Mailpit not working out of the box with ddev

Created on 26 October 2024, 27 days ago

Problem/Motivation

Symfony mailer lite is used as the mailer and this is configured to use dsn 'smtp://mailpit:1025'. This is correct for lando and not ddev.
The ddev overrides for mailpit in settings.ddev.php are suitable for symfony mailer, but not symfony mailer lite.
Although not the cause, the settings.local.php also have inconsistent settings for symfony mailer that refer to mailhog.

Steps to reproduce

Run ./scripts/local/init-project.sh (ddev
DDEV provides mailsetting overrides in settings.ddev.php for symfony mailer (and not symfony mailer lite).
Attempt a password reset
Password reset not sent via mailpit

Proposed resolution

Options:
1. Add a configuration override to settings.local.php (patch below),
2. Change the default and add an override for lando.
2. Switch to symfony mailer (instead of symfony mailer lite). Allows the mail system module to be removed and arguably is a better default for a new project.

Patch to correct the override if staying with symfony mailer lite.

diff --git a/drupal/docroot/sites/default/settings.local.php b/drupal/docroot/sites/default/settings.local.php
index 3ccc340..3bd4d75 100644
--- a/drupal/docroot/sites/default/settings.local.php
+++ b/drupal/docroot/sites/default/settings.local.php
@@ -161,4 +161,9 @@
 $config['rokka.settings']['organization_name'] = 'starterkit-local';
 
 ## Symfony Mailer DSN Settings
-$config['symfony_mailer.mailer_transport.dsn']['configuration']['dsn'] = 'smtp://mailhog:1025';
+# Override the mail dsn (for symfony mailer lite) if using DDEV.
+# DDEV auto generated settings (settings.ddev.php) only override
+# settings for symfony mailer (not symfony mailer lite).
+if (getenv('IS_DDEV_PROJECT') === 'true') {
+  $config['symfony_mailer_lite.symfony_mailer_lite_transport.dsn']['configuration']['dsn'] = 'smtp://localhost:1025';
+}

. Switch the default mailer in the starter

Remaining tasks

Decide on the option and open an MR.

User interface changes

None.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇨🇭Switzerland tcrawford

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024