Ubuntu – Testing Magento 2 Emails Using Mailhog

emailmagento2

I need an easy to use email tester, for Windows I use SMTP4dev which is really good. Mailhog seems to be the equivalent in Ubuntu/Linux.

I downloaded Mailhog, installed Go, and ran it with ./MailHog_linux_amd64 and it is running: http://http://0.0.0.0:8025/ the thing is though it is not getting the emails that Magento 2 is sending.

I tested with a new order email and also a reset password email, and also ran the php bin/magento cron:run to make sure the email is not stuck in the queue. How do you configure Magento 2 with Mailhog?

Best Answer

Found it: https://github.com/mailhog/MailHog/issues/99

and it works great! So steps to make mailhog work with Magento 2:

wget the mailhog binary: https://github.com/mailhog/MailHog/releases/v0.2.0

1) so is for Ubuntu: wget https://github.com/mailhog/MailHog/releases/download/v0.2.0/MailHog_linux_amd64 and you put it somewhere, I put it in /usr/local/etc but put it wherever, you then can make it executable: chmod +x MailHog_linux_amd64

2) Start MailHog_linux_amd64 by command ./MailHog_linux_amd64

3) Edit your php.ini file adjusting the sendmail_path, set it like the link above shows so would be sendmail_path = "/usr/local/etc/MailHog_linux_amd64 sendmail test@example.org" and restart php, I'm using nginx php-fpm7.0 so the command is: service php7.0-fpm restart

4) Try sending an email in Magento, it should showup in mailhog, so point your browser to http://0.0.0.0:8025/ to see it