Tutorials

PostFix HowTo

Setup Postfix for GMail on Mac:

This tutorial loosely follows instructions given in this blog.

In this tutorial we describe how to configure the postfix email delivery system, so that you can send emails from your Mac OS X command line to be delivered to an email receipient via an account at google mail:

  • Supposed your account on gmail.com is “user@gmail.com” with a password “pass”.
  • Become super user for the following commands in the Mac OS X terminal:
  • sudo -s
  • Create a SASL password by replacing user:pass with your own user name and password at GMail in the following command line:
  • echo "smtp.gmail.com:587 user:pass" >> /etc/postfix/sasl_passwd
  • Create a postfix lookup for your SASL password:
  • postmap /etc/postfix/sasl_passwd
  • Make sure that the password file and generated password database file is readable by root only.
  • Append the following configuration options to /etc/postfix/main.cf:
# Minimum Postfix-specific configurations.
mydomain_fallback = localhost
mail_owner = _postfix
setgid_group = _postdrop
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=

# Enable Transport Layer Security (TLS), i.e. SSL.
smtp_use_tls=yes
smtp_tls_security_level=encrypt
tls_random_source=dev:/dev/urandom
  • And exit from the super user session.

Now start postfix:

sudo postfix start

Check if postfix is running:

sudo postfix status

And send an email on the command line to a specific email address:

echo "email message" | mail -s "postfix test" email@address

If anything goes wrong you can diagnose the state of postfix by looking at the log file at /var/log/mail.log.

If you want postfix running all the time then tell launchctl to do so:

sudo launchctl load -w /System/Library/LaunchDaemons/org.postfix.master.plist

Note: On MacOS X 10.5.8 we need to stop the mailinglists service, since it will block Postfix every once in a while:

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.wikid.mailinglists.plist 

Options: