Skip to content

Instantly share code, notes, and snippets.

@angrycub
Created January 2, 2015 17:05
Show Gist options
  • Save angrycub/382f1419957c05e73e25 to your computer and use it in GitHub Desktop.
Save angrycub/382f1419957c05e73e25 to your computer and use it in GitHub Desktop.
Configuring PostFix on OSX 10.10

##Configure Postfix for Gmail SMTP## ###Edit file /etc/postfix/main.cf###

sudo vim /etc/postfix/main.cf

and add in the following to the bottom of the file:

relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_mechanism_filter = plain
smtp_use_tls = yes

###Generate sasl_password if not already exists###

sudo vim /etc/postfix/sasl_passwd

and enter in the following:

[smtp.gmail.com]:587 username@gmail.com:password

Run the following commands

sudo chmod 600 /etc/postfix/sasl_passwd
sudo postmap /etc/postfix/sasl_passwd
sudo launchctl stop org.postfix.master
sudo launchctl start org.postfix.master

And you are done….

###Test your configuration### Now, you should be able to send emails from within the command line e.g. to send the contents of a directory as a tree to an email address

echo "This is a test" | mail -s "Test email from PostFix" your@yourdomain.com
@barrontang
Copy link

Are there any difference between the following:

[smtp.gmail.com]:587 username@gmail.com:password vs. smtp.gmail.com:587 username@gmail.com:password

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