Easily test sending and receiving email locally using MailHog

Tai Bo
3 min readSep 23, 2022

A java application which I work on has a feature to send emails via the corporate SMTP server to notify certain personnel whenever an error occurs. For security reasons, only servers within a certain networks can access the SMTP server and send emails. For instance, the computer which I use to build the application does not have access to the SMTP server. When searching for an email testing tool, I stumbled upon MailHog. Within minutes, I was able to run MailHog and test sending emails without having to deploy the app to the remote servers.

For my situation, all I need is a way to validate the content of the email which my app generates and sends out to the specific addresses. This process is a manual verification, and not of an automated one. For this purpose, MailHog works great and is also extremely easy to setup. I have tested it on a Windows machine with a 64 bit operating system.

MailHog is extremely easy to setup. In fact, I did not have to install anything. I just had to download the executable file for my platform. You can find the MailHog releases here. For me, I downloaded the MailHog_windows_amd64.exe file.

Running the file will open a command prompt windows which display outputs from the app, as shown in the snippets below.

2022/09/21 21:28:49 Using in-memory storage
2022/09/21 21:28:49 [SMTP] Binding to address: 0.0.0.0:1025
[HTTP] Binding to address: 0.0.0.0:8025
2022/09/21 21:28:49 Serving under…

--

--

Tai Bo

Backend developer in .NET core. I enjoy the outdoor, hanging out with good friends, reading and personal development.