Skip to content

Instantly share code, notes, and snippets.

@farinspace
Last active July 16, 2018 18:33
Show Gist options
  • Save farinspace/b047091be6dd0e3e0f06e86b1f303f68 to your computer and use it in GitHub Desktop.
Save farinspace/b047091be6dd0e3e0f06e86b1f303f68 to your computer and use it in GitHub Desktop.
MacOS X postfix relyhost mail setup
...
# append to /etc/postfix/main.cf
relayhost=smtp.sendgrid.net:587
smtp_sasl_auth_enable=yes
smtp_sasl_password_maps=hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options=
smtp_use_tls=yes
smtp_tls_security_level=encrypt
tls_random_source=dev:/dev/urandom
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.postfix.custom</string>
<key>Program</key>
<string>/usr/libexec/postfix/master</string>
<key>QueueDirectories</key>
<array>
<string>/var/spool/postfix/maildrop</string>
</array>
<key>AbandonProcessGroup</key>
<true/>
<key>OnDemand</key>
<true/>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
smtp.sendgrid.net:587 [email]:[password]
# create empty file
sudo touch /etc/postfix/sasl_passwd
# set permissions before entering credentials
sudo chmod go-rwx /etc/postfix/sasl_passwd
# setup credentials
sudi vi /etc/postfix/sasl_passwd
# create lookup table
sudo postmap /etc/postfix/sasl_passwd
# for extra security, remove file once lookup table is created
sudo rm /etc/postfix/sasl_passwd
# create a backup copy
sudo cp /etc/postfix/main.cf /etc/postfix/main.cf~orig
# append config
sudo vi /etc/postfix/main.cf
# create service config
sudo vi /Library/LaunchDaemons/org.postfix.custom.plist
# add mac os service service (be sure correct permissions are set; root:wheel)
sudo launchctl load /Library/LaunchDaemons/org.postfix.custom.plist
# restart macOS to confirm auto loading on boot
# confirm postfix process is running
ps -A | grep postfix
@farinspace
Copy link
Author

tested macOS High Sierra 10.13.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment