‘mail’ from the command line in OS X Leopard (10.5)

This article got me going. I followed the advice of some of the comments and unzipped the whole of roots.zip into /etc/postfix/certs, and did chmod 600 relay_password.

First create /etc/postfix/relay_password with the server name, email account name and password as shown below.

smtp.googlemail.com youremail@gmail.com:yourpassword

Make sure nobody but root can read the file containing your password:

sudo chmod 600 /etc/postfix/relay_password

Then use postmap to create a .db file.

postmap /etc/postfix/relay_password

Make sure the map is ok with

postmap -q smtp.gmail.com /etc/postfix/relay_password

You will need to retrieve the Thawte Premium Server CA from https://www.verisign.com/support/roots.html.

sudo mkdir /etc/postfix/certs
cd /etc/postfix/certs
sudo unzip -j /path/to/roots.zip
sudo openssl x509 -inform der -in ThawtePremiumServerCA.cer -out ThawtePremiumServerCA.pem
sudo c_rehash /etc/postfix/certs

Now you are ready to configure postfix. Add these lines to the bottom of /etc/postfix/main.cf

relayhost = smtp.googlemail.com:587
# auth
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/relay_password
smtp_sasl_security_options = noanonymous
# tls
smtp_tls_security_level = may
smtp_tls_CApath = /etc/postfix/certs
smtp_tls_session_cache_database = btree:/etc/postfix/smtp_scache
smtp_tls_session_cache_timeout = 3600s
smtp_tls_loglevel = 1
tls_random_source = dev:/dev/urandom

Test now by using /usr/bin/mail to send an email. You can check /var/log/mail.log to see if it worked without errors. Leopard enables postfix by default. Launchd watches a directory and will startup when the test email is sent.


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s