In moving an automated process from a linux box over to a mac, I found myself missing cron’s built-in ability to send an email as I switched over to OSX’s launchd. The obvious answer, sending an email from within my bash script, send me looking for an easy way to send an email from the command line, without needing to install sendmail or postfix. Ideally I’d use Gmail as an SMTP service, but not a hard requirement.
A number of articles cited msmtp as a good solution, and this article provided a great overview of how to install it. Furthermore, it supports Gmail and can use the OSX keyring for account info, which are nice. However, in the 5 years since it was written, enough things had changed that I couldn’t follow it directly. Specifically:
I ended up using Macports, since I was missing pkg-config (and probably other stuff) that would have let me build msmtp from source.
Thawte made some cert changes in 2010, and the described config doesn’t work as written.
So here was my process:
Installed msmtp via Macports, including the openssl variant (‘port install msmtp +openssl‘).
Installed the curl-ca-bundle from Macports to replace Thawte.
Created an msmtprc file as described in the earlier instructions, and store at /opt/local/msmtprc. The only change is the location of the cert file, which should now be:
Manually added the account to the OSX keyring and added a .mailrc as described in the earlier instructions.