Setup Mailhog with MAMP Pro to catch outgoing emails

Sometimes a Vagrant box is overkill for a simple website (at Jannes & Mannes we use Trellis a lot to develop WordPress websites) and MAMP is just the best solution. Because MAMP is a useful tool to develop PHP sites locally.

Mailhog is included in Trellis and works out of the box. Just type in your dev URL ending with the Mailhog port 8025 (e.g. website.dev:8025) and you can find all the outgoing emails sent from PHP.

To achieve the same functionality in MAMP, Mailhog needs to be installed on your Mac and the built-in SMTP server “Postfix” should be configured in MAMP.

Installing Mailhog

To install Mailhog on your Mac we use Homebrew Mailhog (we assume you have Homebrew installed already). You can install Homebrew Mailhog using the following command in your terminal:

brew install mailhog

Open http://127.0.0.1:8025 to check if Mailhog is running. Otherwise run brew services start mailhog to start Mailhog.

Configuring Postfix in MAMP Pro

Open MAMP Pro and go to the “Postfix” tab. Make sure the checkbox next to “Include Postfix service in GroupStart” is checked.

Use these setting for Postfix:

  1. Fill in your domain name in the field “Set domain of outgoing e-mails to:”
  2. Check “Use a Smart host for routing”
  3. “Server name:” is 127.0.0.1:1025 (this is the SMTP port Mailhog uses)
  4. Set “Authentication” to “none”
Postfix settings in MAMP Pro

That’s it! Restart MAMP, trigger an email in PHP and go to http://127.0.0.1:8025 in your browser to see if Mailhog receives your email. You can use the Postfix log file to debug Postfix (by default located in /var/log/mail.log ).