Using Gmail as a smart host

Many ISP's these days block outbound SMTP (port 25) from their networks. However, they generally don't block higher ports that are used for encrypted SMTP (port 587). I came across this document that outlines how to set up postfix so you can relay through Gmail's SMTP.

It seems to work pretty well, but you manually have to add the cert's for Gmail's SSL sertificate. On Ubuntu, do the following:

apt-get install ca-certificates
cat /etc/ssl/certs/Thawt* >> /etc/postfix/cacert.pem
postfix reload

One suggestion on the above document is to make sure that you put root@yourhost in /etc/postfix/generic so that system-generated emails from cron jobs actually get delivered properly.

Another suggestion is to create your own 'smtp' account solely for this. This means that you don't have a password that you care about sitting around in plain text on your filesystem somewhere. Gmail accounts are free, so there's no reason not to do this.

When this box was running Ubuntu 6.10, I'd found some elaborate set of scripts to perform this same function. I used this to back up my MythTV database to Gmail so I have a backup of it if something happens to my database. (If I have a hardware failure, I'm screwed anyways)

Basically, the script dumps the database (mythconverg), compresses it, encrypts it, chops it up into 7.5MB chunks, and emails it to myself. I then filter it inside gmail using the + trick (i send email to me+filterme@mydomain.com), and filter on the +filterme to direct stuff.

This script is really hacky, but here it is: