Stratus Guides - Install MailHog

MailHog is a popular tool for testing Email templates on any platform.
  1. In the SSH container, navigate to ~/bin directory and execute the following command:
wget -c https://go.dev/dl/go1.19.5.linux-amd64.tar.gz
  1. Extract archive:
tar -xvf go1.19.5.linux-amd64.tar.gz
  1. Export PATH:
export PATH=$PATH:/srv/bin/go/bin
  1. Navigate to /srv/pwa directory and execute:
go install github.com/mailhog/MailHog@latest
  1. Adjust start.sh file in the /srv/pwa directory or create it fresh with the following details:
#!/bin/bash
export PATH=$PATH:/srv/bin/go/bin
/srv/go/bin/MailHog -ui-web-path /mailhog -smtp-bind-addr 0.0.0.0:10000

Note: If you are already running some NodeJS application, adjust the export path accordingly as an add-on to the current NVM settings.

  1. Test ./start.sh before starting up the Node container from within the Stratus panel. This is how it should look if MailHog is started properly:
  1. Following NodeJs guidelines navigate to your Stratus panel and start the container. If everything remains in the “Running” state, the MailHog container is started successfully and fully functional.

  2. Next, we need to download and install mhsendmail tool and adjust the PHP configuration to use it when sending emails.

cd ~/bin
wget https://github.com/mailhog/mhsendmail/releases/download/v0.2.0/mhsendmail_linux_amd64
chmod +x mhsendmail_linux_amd64
mv mhsendmail_linux_amd64 mhsendmail
  1. Add the following alias to the ~/.bashrc file:
alias mhsendmail='/srv/bin/mhsendmail'
export PATH=$PATH:/srv/bin/go/bin
  1. Create the /srv/smwrap.sh file:
/srv/bin/mhsendmail --smtp-addr=nodejs:10000
  1. Navigate to Stratus panel → PHP → Option section and add the following:
sendmail_path=/srv/smwrap.sh
  1. The last step is to add the following into the Nginx → Includes section area from within the Stratus panel:
location /mailhog {
proxy_pass http://0.0.0.0:8025;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-SSL-offloaded $ssl_offloaded;
proxy_buffer_size          128k;
proxy_buffers              4 256k;
proxy_busy_buffers_size    256k;
}

When you start the container and add the Nginx rule, the UI should look as follows:


Last modified January 1, 0001