Skip to content

Instantly share code, notes, and snippets.

@LogicKahanHai
Forked from 0-Sony/mailhog-postfix.MD
Last active October 7, 2024 06:17
Show Gist options
  • Save LogicKahanHai/22592f5f8a60c1eed8b91d3592901179 to your computer and use it in GitHub Desktop.
Save LogicKahanHai/22592f5f8a60c1eed8b91d3592901179 to your computer and use it in GitHub Desktop.
MailHog + Postfix configuration on Mac Os (work on Mojave)

Configure MAILHOG and POSTFIX on MAC OS (Mojave)

INSTALL BREW

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

If brew is already installed

brew update

INSTALL MAILHOG

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 = "{/path/to/your/mailhog/installation}/bin/MailHog sendmail test@test"

to get your mailhog installation path run the command: brew info mailhog and check for "Installed" keyword in the output

CONFIGURE POSTFIX

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment