ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
If brew is already installed
brew update
brew install mailhog
then run
brew services start mailhog
now, you should be able to see mail at this address: http://127.0.0.1:8025/
open your php.ini
file and search for sendmail_path
. This part could be commented, just uncomment it and add this value :
sendmail_path = /usr/local/Cellar/mailhog/1.0.0/bin/MailHog sendmail test@test
make sure that your mailhog
version is 1.0.0
otherwise you just have to adapt the version in the sendmail_path
To check your mailhog version you can run this command : brew info mailhog
edit the file
/etc/postfix/main.cf
and add these lines at the end :
# For MailHog
myhostname = localhost
relayhost = [localhost]:1025
now you can test to send an email from your terminal :
echo "Test sending email from Postfix" | mail -s "Test Email" [email protected]
If it's not working check if your email is in the queue with this commad :
mailq
If you get an error like
(Host or domain name not found. Name service error for name=localhost type=AAAA: Host not found)
then change your config in the main.cf put previously by this :
# For MailHog
myhostname = localhost
relayhost = [127.0.0.1]:1025