Skip to content

Instantly share code, notes, and snippets.

@Asikur22
Forked from 0-Sony/mailhog-postfix.MD
Created February 5, 2021 13:22
Show Gist options
  • Save Asikur22/bcd8850282bcf6a8676095887412da88 to your computer and use it in GitHub Desktop.
Save Asikur22/bcd8850282bcf6a8676095887412da88 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 = /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

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" random@email.com

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