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.
- 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.
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:
version: "3" services: mailhog: image: mailhog/mailhog:latest restart: always ports: - 1025:1025 - 8025:8025
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:
go get github.com/mailhog/MailHog
Following that, you can use the tool by performing the following:
mailhog -api-bind-addr 127.0.0.1:8025 -ui-bind-addr 127.0.0.1:8025 -smtp-bind-addr 127.0.0.1:1025
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:
wget https://github.com/mailhog/mhsendmail/releases/download/v0.2.0/mhsendmail_linux_amd64 sudo chmod +x mhsendmail_linux_amd64 sudo mv mhsendmail_linux_amd64 /usr/local/bin/mhsendmail
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.
sendmail_path = /usr/local/bin/mhsendmail
Try sending a message using the CLI in the following manner:
mhsendmail firstname.lastname@example.org <<EOF From App <email@example.com> To Test <firstname.lastname@example.org> Subject: Test message Some content! EOF
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.
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:
- SMTP Bucket