How to install MailHog on Mac M1?

How to install and configure MailHog on Mac M1 – In this article, we’ll explore how to install and configure MailHog on a local Mac M1 environment.

I found numerous articles on how to install and set up MailHog on Windows, Linux, and even Mac. Despite following many guides for Mac, I still couldn’t configure MailHog on my Mac M1.

Installing MailHog on Mac M1

To install mailHog you need to run following command and i assumed you already have installed PHP and brew on your system.

After Success fully install the mailHog using above command need to run below command to start mailHog as services

You can verify MailHog is up and running by below command, You can see this is up and running.

Now visit this url – http://0.0.0.0:8025/ , you can see the mailHog Interface in your browser. Where you can check your emails inbox.

Configure with Php

Find the php.ini path and update the sendmail_path. In Mac M1 mostly the path will be as follow
/opt/homebrew/etc/php/8.1/php.ini as per your installed php version you can update the php.ini.

Run sudo nano /opt/homebrew/etc/php/8.1/php.ini and update the sendmail_path as follow.

Important Note: Many articles reference the MailHog path as /usr/local/bin/mailhog for MacOs. However, on a Mac M1, the correct path is /opt/homebrew/bin/mailhog. Make sure not to overlook this detail—I missed it initially and spent a lot of time figuring it out.

Testing

You can test MailHog in various ways, such as running a PHP script and updating the email function. However, my primary goal for installing MailHog locally was to check Magento 2 transactional emails. To do this, update the code inside the health_check.php file located in the pub directory, and then run the file.

That’s it, very important heads up here is correctly setup the path on your php.ini. Hope this article may help you to setup MailHog on you Mac M1. Have a grate day