Backing Up a Gmail Account With Fetchmail on FreeBSD
Gmail is awesome. But I do not want Gmail to be the only location where all my important emails are stored. For this reason I use fetchmail to automatically archive any emails sent to my Gmail account on my own FreeBSD server. This guide describes how I currently have this set up.
Ingredients
- FreeBSD 8.2
- Fetchmail 6.3.20
Installing Required Packages
If you haven't already, install the fetchmail port with the following commands.
$ cd /usr/ports/mail/fetchmail $ make install clean
We also need to install the ca_root_nss port. This port contains all root certificates from certificate authorities included in Mozilla applications (i.e. Firefox and Thunderbird).
$ cd /usr/ports/security/ca_root_nss $ make install clean
Configuring
First, make sure that you have POP access to your Gmail account enabled. This can be done from the Gmail settings page, under the tab ‘Forwarding and POP/IMAP’.

Customize the following snippet and place it in ~/.fetchmailrc. If you get an error about a fingerprint mismatch then you should replace the fingerprint in the snippet below by the fingerprint in the error message.
poll pop.gmail.com proto pop3 user "<your Gmail address>" pass "<your Gmail password>" options keep ssl sslfingerprint "90:9A:84:92:E7:60:7C:A2:45:73:C9:11:D7:FE:7D:8A" sslcertck sslcertfile /usr/local/share/certs/ca-root-nss.crt
Testing
That should be all, now we can test our configuration.
$ fetchmail -d0 -v pop.gmail.com
If everything is set up correctly then the output should look something like this:
fetchmail: 6.3.20 querying pop.gmail.com (protocol POP3) at Sun Oct 16 19:25:01 2011: poll started Trying to connect to 209.85.227.109/995...connected. fetchmail: Server certificate: ... fetchmail: POP3> QUIT fetchmail: POP3< +OK Farewell. fetchmail: 6.3.20 querying pop.gmail.com (protocol POP3) at Sun Oct 16 19:25:02 2011: poll completed