Configuring msmtp on OSX Snow Leopard to send through gmail
This recipe covers setting up msmtp on OSX Snow Leopard to enable command line tools like mailx to deliver email through Gmail. One advantage of this recipe is that it does not touch any Apple-provided system configuration files, so it is independent from OS updates.
Precondition: MacPorts should be installed.
1. Install msmtp with Macports.
sudo port install msmtp
2. Install the certificate bundle.
sudo port install curl-ca-bundle
3. Edit ~/.msmtprc to contain:
account default
host smtp.gmail.com
port 587
timeout 30
auth on
user YOUR@EMAIL.HERE
password YOURPASSWORD
auto_from off
from YOUR@EMAIL.HERE
tls on
tls_starttls on
tls_trust_file /opt/local/share/curl/curl-ca-bundle.crt
4. Set permissions on .msmtprc:
chmod 600 ~/.msmtprc
5. Test the configuration. The test file should start with a blank line.
msmtp -d TEST@EXAMPLE.COM < hello.txt
6. Edit ~/.mailrc to contain:
set sendmail=/opt/local/bin/msmtp
This recipe is based in part on a useful article at magictalong.
