I recently needed to modify the emails that a client project sends out. It was set up to send via SMTP and so the easiest way to do this for me was to add a local MailHog instance and point the application at it.

Manually running via Docker

The quickest and easiest way to do this is via Docker.

Manually, we can do:

This will run MailHog with the SMTP port exposed on localhost port 1025 and the web interface on 8025.

Now you can configure the app’s SMTP config and away you go.

Test via telnet

You can test via telnet fairly easily if you have it installed:

Type each line out and press Enter between each one and you’ll see the new email in MailHog’s web interface:

Docker compose

As I already had a Docker Compose setup for this project, I added the following to my docker-compose.yml:

MailHog’s logs are quite chatty, so adding driver: 'none' to the logging section will turn them off if you don’t need them.


That’s it. I used to use Mailcatcher and still do on one project, but MailHog’s Docker container makes it much easier and quicker to set up.