Mailhog installation on ubuntu


MailHog is an email-testing tool with a fake SMTP server underneath. It encapsulates the SMTP protocol with extensions and does not require specific backend implementations. MailHog runs a super simple SMTP server that hogs outgoing emails sent to it. You can see the hogged emails in a web interface. MailHog is a portable tool built with Golang. You can run it on any supported platform, and Golang binary files allow you to set it up very simple – just copy and launch.


MailHog is designed for app developers. They can use this tool to test the app’s email sending more efficiently. Unlike a real SMTP server, a fake one avoids issues related to server configuration or anything like that. MailHog just lets you send emails to any recipient and stores them for display. Also, you can view the hogged emails using the web UI, or retrieve them using an API for automated testing. Let’s check out what else is available with this email-testing tool.


Mailhog is developed in GO language. You first need to install Go on your machine, if you don't have.

sudo apt-get install golang-go
mkdir gocode
echo "export GOPATH=$HOME/gocode" >> ~/.profile
source ~/.profile

Execute above commands one by one.

Step 2:
go get
go get
Step 3:

Now we should move it to bin directory so that it can be executed from everywhere.

sudo cp /home/{user}/gocode/bin/MailHog /usr/local/bin/mailhog
sudo cp /home/{user}/gocode/bin/mhsendmail /usr/local/bin/mhsendmail
Step 4:

Configure it with PHP. Open php.ini file and change sendmail_path to following.

sendmail_path = /usr/local/bin/mhsendmail

To start mailhog, just run mailhog in terminal.

View emails

To view email visit


Configuration in nishchay framework
  1. Set host to localhost
  2. Set port to 1025

Leave username and password null.

Autostart on boot

To auto start mailhog on boot execute below command:

sudo systemctl enable mailhog

To check if its running run following command

sudo systemctl status mailhog