Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Send email from OSX Command line using gmail as SMTP

#Step 1: Update /etc/postfix/

$ sudo vim /etc/postfix/

Add the following lines, anywhere really, but preferably under the relayhost section:

relayhost =
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_use_tls = yes
smtp_sasl_mechanism_filter = plain

#Step 2: Create /etc/postfix/sasl_passwd

sudo vim /etc/postfix/sasl_passwd

Add the following information. Note update and with your information <username><password>

#Step 3: Restart postfix

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


$ echo "Hello" | mail -s "Test" <someone>


$ tail -f /var/log/mail.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment