Google Apps Email + msmtp on Ubuntu

January 26, 2009

I like to be able to send email from my server so that I can email myself reminders, important server stats, backups, and other minor things. I had previously set up postfix to do this, but I realized that this was overkill since I use Google Apps as my actual mail client I didn't need my server to be able to receive any mail at all. I poked around the net and found a helpful guide for installing and configuring msmtp that was tailored for Mac and Rails. After trying several long ways to get things setup, I eventually settled on the following:

  1. apt-get install msmtp (you will also need openssl if you don't have it already)
  2. Several guides require you to manually fetch the Thawte cert that Gmail uses from here, but this is already on you system as /etc/ssl/certs/Thawte_Premium_Server_CA.pem if you have the ca-certificates package installed.
  3. Now you just need to configure msmtp to connect to Gmail.

This file can either be saved as ~/.msmtprc for current user configuation or as /etc/msmtprc for global configuration.

account gmail
host smtp.gmail.com
port 587
auth on
user <user>@<domain>
password <password>
tls on
tls_trust_file /etc/ssl/certs/Thawte_Premium_Server_CA.pem
from <user>@<domain>

account default: gmail

If you have configured things correctly, you should be able to see some info on the Gmail server by running 'msmtp --serverinfo'. You should also be able to send mail by running 'msmtp <recipient>' and entering you message on stdin.

Check out my other pages tagged "blog".