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)