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.

Installation

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

brew install mailhogCode language: Bash (bash)

Start

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

brew services run mailhogCode language: Bash (bash)

You can then access the web interface via http://0.0.0.0:8025, 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 sendmailCode language: JavaScript (javascript)

2 thoughts on “macOS: Install MailHog via brew

Leave a Reply to Matthias Kittsteiner Cancel reply

Your email address will not be published. Required fields are marked *