Skip to content

Instantly share code, notes, and snippets.

@aduzsardi
Forked from viktorpetryk/mailhog-install.md
Created October 10, 2019 08:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aduzsardi/2b3e35a6a35656e1be749f808ae7f5b4 to your computer and use it in GitHub Desktop.
Save aduzsardi/2b3e35a6a35656e1be749f808ae7f5b4 to your computer and use it in GitHub Desktop.
MailHog installation on Ubuntu

Install & Configure MailHog

  1. 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
  1. 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
  1. Configure php.ini file (for needed version)
sudo sed -i "s/;sendmail_path.*/sendmail_path='\/usr\/local\/bin\/mailhog sendmail magento-dev@example.com'/" /etc/php/7.0/apache2/php.ini
sudo sed -i "s/;sendmail_path.*/sendmail_path='\/usr\/local\/bin\/mailhog sendmail magento-dev@example.com'/" /etc/php/7.1/apache2/php.ini
  1. Restart Apache to apply changes in php.ini file.
sudo service apache2 restart
  1. Open url in browser
http://localhost:8025/
  1. When any php script send an email, it will be catched by MailHog and you can read it in the UI.

  2. Configuring MailHog

Add to your .bashrc

# Set message storage: memory | mongodb | maildir
export MH_STORAGE=maildir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment