Setup MailHog and MAMP on macOS


Hey 👋,

recently I was in a hurry and I ended up usingthe traditional MAMP tool for macOS for a personal project.

This project involved sending emails, and I wanted to test what I was sending locally.

I knew MailHog so I decided to set it up in local. It was an easy thing, but not as straightforward as I would have liked.

Here you have the steps I’d have loved to find to configure MailHog and MAMP on macOS:

  1. Install MailHog with brew install mailhog.
  2. Start the mailhog process by running mailhog in a terminal.
  3. Forget about MAMP.
  4. Edit your postfix configuration file /etc/postfix/main.cf (you can do it with sudo vim /etc/postfix/main.cf).
  5. Add at the bottom the following piece of code:
    # For MailHog
    myhostname = localhost
    relayhost = [localhost]:1025
    
  6. Save and exit (if you are using vim :x).
  7. Restart MAMP (Not sure if this is really necessary).
  8. Go and use your mail() function normally in PHP.
  9. You should see your emails appearing in the mailhog interface at http://localhost:8025/.
  10. Enjoy!

Was it helpful? Click on the like button below to let me know!