Docksal Maintainers Blog

Official Docksal blog. Docksal tips and tricks. Advices and news.

Follow publication

Mailhog and Swiftmailer in Local Development

--

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:

version: 2.1services:
# MailHog
mail:
extends:
file: ${HOME}/.docksal/stacks/services.yml
service: mail

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.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Published in Docksal Maintainers Blog

Official Docksal blog. Docksal tips and tricks. Advices and news.

Written by Shelane French

Follower of Jesus Christ, Wife, Mother, Daughter, Sister, Aunt, Web Developer, Singer, Guitarist, Faithful SF Giants and SF 49ers fan, and a Mac Enthusiast

No responses yet

Write a response