MailHog is an email testing tool for developers. It allows to configure your application to use MailHog for SMTP delivery. MailHog catches all outgoing emails and sends them to itselfs. All emails can then be viewed in a web UI or they can be retrieved with a JSON API. It is also optionally possible to release messages to real SMTP servers. The easiest way to get started with MailHog is to pull the docker image:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker pull mailhog/mailhog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker pull mailhog/mailhog |
Once downloaded, MailHog can be started as follows:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker run -d \ | |
–restart unless-stopped \ | |
–name mailhog \ | |
-p 1025:1025 \ | |
-p 8025:8025 \ | |
mailhog/mailhog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker run -d \ | |
–restart unless-stopped \ | |
–name mailhog \ | |
-p 1025:1025 \ | |
-p 8025:8025 \ | |
mailhog/mailhog |
Port 1025 is the SMTP port and port 8025 is the HTTP server for the web UI. As MailHog is running in a docker container, we have to use the local docker IP instead of localhost. The web UI can be called via http://192.168.99.100:8025/
Among other things, I’m using MailHog for configuring email notification from Jenkins. So, I had to set up MailHog for Jenkins. I’m using the email extension plugin that allows to configure a lot more aspects of email notifications than the default normal mailer plugin. At Manage Jenkins → Configure System under Extended Email Notification you have to configure the following:
As SMTP Server we also need to enter the local docker IP. Setting the Content Type to HTML allows to use HTML tags in emails that makes them more flexible.