MacOS Sierra High comes with preinstalled postfix
. Follow these steps to configure it on a local system:
sudo nano /etc/postfix/sasl_passwd
- Add this to the file
smtp.gmail.com:587 [email protected]:PASSWORD
Replace EMAIL
with your gmail username and replace PASSWORD
with your gmail password.
- Create a lookup table
sudo postmap /etc/postfix/sasl_passwd
- Open postfix's
main.cf
sudo nano /etc/postfix/main.cf
- Edit these values if they are not set already
mail_owner = _postfix
setgid_group = _postdrop
- Add these fields at the end of the file (I am choosing
mtp.gmail.com
as myrelayhost
to send email from gmail account. You can choose any other SMTP relayhost)
#Gmail SMTP
relayhost=smtp.gmail.com:587
# Enable SASL authentication in the Postfix SMTP client.
smtp_sasl_auth_enable=yes
smtp_sasl_password_maps=hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options=noanonymous
smtp_sasl_mechanism_filter=plain
# Enable Transport Layer Security (TLS), i.e. SSL.
smtp_use_tls=yes
smtp_tls_security_level=encrypt
tls_random_source=dev:/dev/urandom
If you are using gmail then you must have to enable less secure app access.
-
Open
/System/Library/LaunchDaemons/com.apple.postfix.master.plist
sudo nano /System/Library/LaunchDaemons/com.apple.postfix.master.plist
- Remove these lines
<string>-e</string>
<string>60</string>
and add these lines
<key>KeepAlive</key>
<true/>
- Reload and relaunch the deamon
sudo launchctl unload /System/Library/LaunchDaemons/com.apple.postfix.master.plist
sudo launchctl load /System/Library/LaunchDaemons/com.apple.postfix.master.plist
Test by sending a mail
echo "Postfix setting test" | mail -s "Hello Postfix" "[email protected]"
Replace [email protected]
with the email id of recipent.
mailq
: Check mails in the queue and errors if mail not sent.sudo postfix flush
: Flush the queue.sudo postsuper -d ALL
Delete mails in the queue.sudo rm /var/mail/$USER
Remove all mails from local host.sudo postfix start
Start postfix mail system.sudo postfix stop
Stop postfix mail system.sudo postfix reload
Reload postfix mail system.
I'm kinda worried that you need to disable SIP. Does that mean that Apple installs postfix, but it's not intended to be used?