Useful for intercepting all PHP mails in a web interface when developing on your localhost. This uses the mhsendmail command for the PHP configuration instead of the normal sendmail command to avoid sending mails to the WWW when testing.
-
install go
-
install mhsendmail
go get github.com/mailhog/mhsendmail
-
install mailhog
sudo port selfupdate && sudo port install mailhog
-
test mailhog running
sudo lsof -nP -i4TCP:8025 | grep LISTEN\n sudo lsof -nP -i4TCP:1025 | grep LISTEN\n
-
php.ini changes
[mail function] SMTP = sendmail_from = [email protected] sendmail_path = "/Users/joram/go/bin/mhsendmail"
-
restart apache
-
test php mail
php -r "\$from = \$to = '[email protected]'; \$x = mail(\$to, 'subject'.time(), 'Hello World', 'From: '. \$from); var_dump(\$x);"
-
test mailhog inbox