I recently updated the Simplenews module for my Drupal site and I needed to do some serious testing. Going from Simplenews 1.0-beta1 to 2.0-beta2 wasn’t a simple task, but it was necessary for our Drupal 9 preparation and failure was not an option. Testing is important for any module update, but being able to test sending emails in a local development environment was key here.
We already had MailHog setup and I noticed that I was not getting any emails when I expected to. Not only was I not getting them from a newsletter being published, I wasn’t getting them even running the email test through Swift Mailer. The settings necessary for the Docksal environment are different than what was set on the server.
Adding MailHog for Docksal is simple. The docksal.yml file should contain:
For the Swift Mailer settings for Docksal, I added this to my local.settings.php file:
* Mail configuration for local mail.
$config['swiftmailer.transport']['transport'] = 'smtp';
$config['swiftmailer.transport']['smtp_host'] = 'mail';
$config['swiftmailer.transport']['smtp_port'] = '1025';
$config['swiftmailer.transport']['smtp_encryption'] = 0;
$config['swiftmailer.transport']['smtp_credential_provider'] = 'swiftmailer';
Now I have Swift Mailer sending mail and MailHog receiving it.