Taken from Using MacOSX Lion command line mail with Gmail as SMTP
Edit file /etc/postfix/main.cf
sudo vim /etc/postfix/main.cf
and add in the following below the commented out relayhosts :-
myhostname = smtp.gmail.com
.
.
.
# SASL SUPPORT FOR SERVERS
#
# The following options set parameters needed by Postfix to enable
# Cyrus-SASL support for authentication of mail servers.
#
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_use_tls = yes
sudo vim /etc/postfix/sasl_passwd
and enter in the following:-
[smtp.gmail.com]:587 [email protected]:password
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
test by sending the contents of a directory to an email address with the following:
tree /var/www/somefolder | mail -s "contents" [email protected]
If you receive the following error:
send-mail: fatal: chdir /Library/Server/Mail/Data/spool: No such file or directory
you can do the following:
sudo mkdir -p /Library/Server/Mail/Data/spool
sudo /usr/sbin/postfix set-permissions
sudo /usr/sbin/postfix start
as per this question.
NB: If things aint sending / receiving, and you're getting notices, check that the mail servers you're using are actually working!
NOTE: A crappy way to get around Google's
Someone just tried to sign in to your Google Account [youremail]@gmail.com from an app that doesn't meet modern security standards.
is to enable less secure apps on your account: https://www.google.com/settings/security/lesssecureapps. Do this at your own discretion.
this is not working. Close. I made some progress. But I am getting mailer daemons using the totally incorrect details here.
It is trying to send mail from [user]@smtp.gmail.com (where user is my mac username without the brackets)
I definitely setup my sasl_passwd, and I am using the email in the form of [account]@gmail.com:[password]
So, why it trying to send mail using my mac user @ smtp.gmail.com ? I think that may be the issue?? How do I fix this?