macOS: Install MailHog via brew

MailHog can be used to reliable test sending emails in your local development environment. It catches sent emails and displays them in an own web user interface.

MailHog can be installed without a hassle via brew in macOS.


You can start the installation via the following command in the Terminal:

brew install mailhog
Code language: Bash (bash)


To start MailHog afterwards, just enter the following command in the Terminal:

brew services run mailhog
Code language: Bash (bash)

You can then access the web interface via, which looks like this:

Web interface of MailHog
The web interface of MailHog

Every received email can be accessed as if you were in a webmail app.

Catching all emails from PHP

To make sure that every email that is sent via PHP is being catched by MailHog and not being send anywhere else, you should adjust the sendmail_path in your php.ini. There you can define MailHog as used program to send emails:

sendmail_path = /usr/local/bin/MailHog sendmail
Code language: JavaScript (javascript)

2 thoughts on “macOS: Install MailHog via brew

Leave a Reply

Your email address will not be published.