This is a simple way to install mailhog, might not be the best solution for everyone, you can look for repositories, still have to register the binary in the PATH, among other things, this is a manual simple install.
Download mailhog from the releases page on github: https://github.com/mailhog/MailHog/releases
Save the binary at /opt/mailhog/mailhog
Give it executable permission chmod +x /opt/mailhog/mailhog
Download the gist: https://gist.github.com/renatomefi/d133fea9cb5a7b00f91edb24b83d9a31#file-init-d-mailhog-sh
Put it at /etc/init.d/mailhog
Give it executable permission chmod +x /etc/init.d/mailhog
Register it to system startup: update-rc.d mailhog defaults
Protect it with password:
Generate a password using /opt/mailhog/mailhog bcrypt MySuperPassword
output: $2a$04$BqpzxoGr2TfYdYiOeH1OjO9mSKeTzisJDgcDKIWNBNHgDWlijCOiC
Create a file /opt/mailhog/auth
with the content:
myusername:$2a$04$BqpzxoGr2TfYdYiOeH1OjO9mSKeTzisJDgcDKIWNBNHgDWlijCOiC
Open in the browser the ip of the machine on the port 8025, i.e.: http://localhost:8025
If you want to serve mailhog on a shared web server you can do something like in your nginx default file:
/etc/nginx/sites-enabled/default
location /mailhog/ {
proxy_pass http://127.0.0.1:8025/;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
Or if you have a hostname you can go for a new vhost config:
/etc/nginx/sites-enabled/mailhog
server {
listen 80;
server_name localhost;
location /mailhog/ {
proxy_pass http://127.0.0.1:8025/;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}