Stratus Guides - Install MailHog
MailHog is a popular tool for testing Email templates on any platform.
- 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
- Extract archive:
tar -xvf go1.19.5.linux-amd64.tar.gz
- Export PATH:
export PATH=$PATH:/srv/bin/go/bin
- Navigate to /srv/pwa directory and execute:
go install github.com/mailhog/MailHog@latest
- 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.
- 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:
-
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.
-
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
- Add the following alias to the ~/.bashrc file:
alias mhsendmail='/srv/bin/mhsendmail'
export PATH=$PATH:/srv/bin/go/bin
- Create the /srv/smwrap.sh file:
/srv/bin/mhsendmail --smtp-addr=nodejs:10000
- Navigate to
Stratus panel → PHP → Option
section and add the following:
sendmail_path=/srv/smwrap.sh
- 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:
Feedback
Was this page helpful?
Glad to hear it! Have any more feedback? Please share it here.
Sorry to hear that. Have any more feedback? Please share it here.
Last modified January 1, 0001