DEV Community

Aubrey Portwood
Aubrey Portwood

Posted on • Edited on

4

How I configured (Laravel) Valet + PHP to send ALL email to Mailhog on Mac w/ Homebrew

I needed to configure PHP + Valet to send any and all emails to Mailhog. This is how I configured my system:

Basically:

brew install mailhog
brew services start mailhog
Enter fullscreen mode Exit fullscreen mode

Then in /opt/homebrew/etc/php/<VERSION>/conf.d/z-php.ini Add:

sendmail_path=/opt/homebrew/bin/mailhog sendmail
Enter fullscreen mode Exit fullscreen mode

Then:

brew services restart php
valet restart
Enter fullscreen mode Exit fullscreen mode

...and if you are using valet isolate in a specific site, also:

valet isolate php@<VERSION>
Enter fullscreen mode Exit fullscreen mode

This should tell that version of PHP to send ANY email via /opt/homebrew/bin/mailhog sendmail which should end up in the Mailhog UI at http://127.0.0.1:8025.

You can also:

valet proxy mailhog.test http://127.0.0.1:8025
Enter fullscreen mode Exit fullscreen mode

And use mailhog.test to access Mailhog.

Code

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

Top comments (1)

Collapse
 
leslieeeee profile image
Leslie

Have you tried ServBay.dev?
It's a much easier tool for PHP developers, providing a user-friendly experience, especially for beginners. It supports all versions of PHP, MariaDB, PostgreSQL, as well as Redis and Memcached. You can run multiple PHP instances simultaneously and switch between them effortlessly. It also offers easy updates without the need to configure environment variables. This tool has greatly simplified my PHP development and is definitely worth trying!

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay