- Download and make it executable
wget https://github.com/mailhog/MailHog/releases/download/v1.0.0/MailHog_linux_amd64
sudo cp MailHog_linux_amd64 /usr/local/bin/mailhog
sudo chmod +x /usr/local/bin/mailhog
- Make MailHog as a service
%user% = your username in the system
sudo tee /etc/systemd/system/mailhog.service <<EOL
[Unit]
Description=Mailhog
After=network.target
[Service]
User=%user%
ExecStart=/usr/bin/env /usr/local/bin/mailhog > /dev/null 2>&1 &
[Install]
WantedBy=multi-user.target
EOL
systemctl daemon-reload
systemctl enable mailhog
- Configure php.ini file (for needed version)
sudo sed -i "s/;sendmail_path.*/sendmail_path='\/usr\/local\/bin\/mailhog sendmail [email protected]'/" /etc/php/7.0/apache2/php.ini
sudo sed -i "s/;sendmail_path.*/sendmail_path='\/usr\/local\/bin\/mailhog sendmail [email protected]'/" /etc/php/7.1/apache2/php.ini
- Restart Apache to apply changes in php.ini file.
sudo service apache2 restart
- Open url in browser
http://localhost:8025/
-
When any php script send an email, it will be catched by MailHog and you can read it in the UI.
-
Configuring MailHog
Add to your .bashrc
# Set message storage: memory | mongodb | maildir
export MH_STORAGE=maildir