You might want to satisfy your curiosity by finding out the status of each email you send to a customer. This will help you determine if the client got the email or not.. Using some helpful email testing tools, you can use a program called MailHog to verify that your emails were delivered.

Read on to learn more about MailHog and to know if it is worth it.

What is MailHog and Why Might You Need it?

MailHog is a tool for testing emails that hides a bogus SMTP server. It does not need a specific backend implementation because it encapsulates the SMTP protocol with extensions. A portable tool made with Golang is called MailHog. Any platform that supports Golang binary files can run it, and installation is as easy as copying and launching.

Why Does it Exist?

MailHog's target market is app developers. They can test the app's email sending more effectively using this tool. You can send emails to any recipient using MailHog, which also stores them for display.

MailHog features

  • You do not need to install MailHog because it is a small tool.
  • ESMTP is supported by MailHog, along with SMTP AUTH and PIPELINING.
  • You can list, retrieve, and delete messages using the HTTP API.
  • Using EventSource, real-time updates are accessible.
  • The stolen emails are kept either in memory or in MongoDB.
  • You can download separate MIME components.
  • Using MailHog's web interface, you can view emails with multipart MIME and encoded headers.
  • HTTP basic authentication for MailHog Web UI and API.

MailHog is a tool that, as was stated earlier, does not require installation. However, downloading and installation are still necessary. The options for doing this are numerous.

Visit GitHub to download MailHog.

Choose the MailHog version that is compatible with your platform from GitHub and download it. You can now run it without any outside dependencies.

Set up MailHog using Docker

Mailhog can be started in a docker container using docker compose.

Docker Compose

A Docker app running in multiple containers is called Compose. To configure services for your application, use a YAML file in this instance. To configure MailHog with this tool, make a file called docker-compose.yml and copy the following lines into it:

Start mailhog by running docker-compose up -d mailhog. This creates the container and launches it. Docker will instantly download the MailHog image if it's not present.

Set up MailHog using a Golang Package

Alternatively you can run MailHog as a golang package. Installing Golang is the first step. Depending on your platform, you can do this in several ways using the options presented here. Now you can install MailHog with:

Following that, you can use the tool by performing the following:

What is Mhsendmail?

MailHog uses mhsendmail as a sendmail substitute. It guarantees that emails will be sent through the MailHog-managed localhost:1025 SMTP server. Should it be required for testing, install MailHog. The inability to accidentally send something outside of your computer as a result of incorrect SMTP server settings is one advantage of using mhsendmail. Consequently, be sure to install it as well.

As a result, be sure to install it too.

Then, add the path to your system so that it is reachable after downloading it from GitHub. Here's how it appears in Ubuntu as an example:

After installing it, you must connect your application to MailHog and set it up to use mhsendmail rather than sendmail. This is how it appears, for, in the php.ini file.

Try sending a message using the CLI in the following manner:

How MailHog works

You must send an email from your app, terminal, or even PowerShell to test how MailHog works.

The following CL script will send an email using the current PHP settings. As previously mentioned, it requires altering the sendmail path in the php.ini configuration file.

Conclusion

MailHog is typically a helpful tool for testing the email-sending capabilities of your app. Although it doesn't have many features, you can still retrieve your emails while storing them using the API.

It only needs a few adjustments to be set up; installation is not necessary. There are other options if you require a professional solution besides MailHog. Here are some options you can choose from:

  • MailSlurp
  • SMTP Bucket
  • FakeSMTP
  • LunaticSMTP.