This script will enable and configure command line email on OSX. It basically does what is described here.
$ sudo bash -c "$(curl -sSL https://raw.github.com/roubles/postfixconf/master/postfixconf.sh)"
Note: This must be done as sudo.
$ sudo ./postfixconf.sh
Type the SMTP hostname and port (example: smtp.gmail.com:587): smtp.gmail.com:587
Type the full username (example: [email protected]): [email protected]
[email protected]'s Password:
Confirm [email protected]'s Password:
Working...
That relay host smtp.gmail.com:587 is already in /etc/postfix/main.cf. Attempting to update.
That relay host is already in /etc/postfix/sasl_passwd. Attempting to update.
Configuring gmail smtp
Updating /etc/postfix/main.cf
Updating /etc/postfix/sasl_passwd
NOTE! For gmail you must enable less secure apps for postfix to work: https://www.google.com/settings/security/lesssecureapps
Restarting postfix
Sending test email to [email protected]
You are done. Check [email protected]'s email.
Do you want to tail /var/log/mail.log [y|n]:n
You should now be able to send emails as such:
$ echo "42" | mail -s "The answer to life the universe and everything" [email protected]
If you are having issues, checkout /var/log/mail.log
$ tail -f /var/log/mail.log
You can see your outgoing mail queue as follows:
$ mailq