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 mailhogCode language: Bash (bash)
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:
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: