Installing Mailhog
Last updated
Last updated
is similar to MailTrap in that it intercepts all email messages being sent from your application and displays them in a simple web interface. Mailhog is currently used by the Elentra Developer Docker environment to facilitate email testing by developers.
If you need to test features in Elentra that send out emails in your Development / Staging / Test environments, then the following instructions will help you install Mailhog on your servers.
To install Go, you will need to connect to your web server and execute the following commands:
Add the following line at the bottom of the /etc/profile
file.
Save and exit the file. Refresh the path, exit out of superuser mode and verify that go is installed:
Reference:
Run the following to install and run the Mailhog server:
Leave Mailhog running from the command line until you have finished installing and testing mhsendmail
below. (Later we will add mailhog as a service that runs in the background automatically, so this is only needed temporarily.)
mhsendmail
is a sendmail
replacement that will ensure that all emails are routed to Mailhog.
Clone and build mhsendmail
:
The current release tags of mhsendmail
(v0.2.0
and earlier) do not support the -t
flag. The master
branch of mhsendmail
is required to allow the -t
flag.
To test mhsendmail
, you can copy and paste the following at the command prompt:
At this point you should be able to see this message in Mailhog in your web browser.
Next we need to make the system use mhsendmail
instead of sendmail
. (This is so we are sure that emails are sent to Mailhog and don't get out into the wild.)
On the web application server edit the php.ini
file.
Search for sendmail_path
. Comment out the existing entry and add a new entry.
Save and close the file. Restart the supervisord
service, to reload php.ini
:
Elentra also uses the sendmail path specified in the settings-xxx.inc.php
files. Change the SENDMAIL_PATH
constant in the settings-staging.inc.php
file as follows.
Save the file, commit, then deploy the change.
Once you have Mailhog installed and Elentra pointed to it for sending mail, you will want to set up a Service to restart Mailhog when the server reboots.
If you have Mailhog manually running from the command line, you will want to exit out of it at this point.
Create a new Mailhog service:
Start the service by issuing the following command.
To verify that the service is running, issue the following command.
To access the Mailhog interface, use your browser to navigate to port 8025 on the web server. e.g.
Reference:
Reference:
Reference:
Reference: