DEV Community

Graham Crocker
Graham Crocker

Posted on • Edited on

Send emails with php on mac quickly with mailhog and mhsendmail

Install Mailhog
brew update && brew install mailhog && brew services start mailhog

Check whether PHP can send mail

php -a

mail('test@test.com', 'subject', 'test');
Enter fullscreen mode Exit fullscreen mode

Check http://0.0.0.0:8025/

If nothing appears the easiest way to fix this is to install MHSendmail

brew install go

go install github.com/mailhog/mhsendmail@latest

Get your php version and create a new file with respect to your version

php --ini
/usr/local/etc/php/X.X/conf.d/80-sendmail.ini

sendmail_path = /Users/xxxx/go/bin/mhsendmail
Enter fullscreen mode Exit fullscreen mode

Restart PHP and try send mail again, it should work!

Top comments (0)

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay