Email Testing with MailHog

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:


docker pull mailhog/mailhog

view raw

docker_mailhog

hosted with ❤ by GitHub


docker pull mailhog/mailhog

view raw

docker_mailhog

hosted with ❤ by GitHub

Once downloaded, MailHog can be started as follows:


docker run -d \
–restart unless-stopped \
–name mailhog \
-p 1025:1025 \
-p 8025:8025 \
mailhog/mailhog


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/

mailhog_webui

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:

extendedemail

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.

Werbung

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit deinem WordPress.com-Konto. Abmelden /  Ändern )

Facebook-Foto

Du kommentierst mit deinem Facebook-Konto. Abmelden /  Ändern )

Verbinde mit %s