Benad's Web Site

This may be just my own paranoia at losing data, but I have the habit of doing backups of all my emails, for nearly a decade now. This seems odd in this age of “cloud computing” and gigabytes of storage for your Gmail inbox, but what if you lose your account?

For Gmail, I use the Python script Getmail. I roughly followed the instructions from this blog post by Matt Cutts, which worked great on my Mac. I can imagine that doing so on Windows would involve somehow Cygwin and some ungodly contraption to make cron jobs work on Windows.

By the way, I do all my email backups in “mbox” format, which is essentially a plain text flat file. You can easily open it with mutt -R -f mboxfile.txt, and it tends to withstand data corruption much better that any other format.

I could use Getmail too for my iCloud account, which is also accessed through IMAP, but I like being fancy and copy the emails to an mbox file using Apple’s Mail itself. To do so, I run a Dovecot server on my Mac and make it store all the emails in an mbox file. Behind the scenes Dovecot will use index files to make manipulations on that mbox file faster.

Installing it and making it run is quite easy with MacPorts:

sudo port install dovecot2 mutt
cd /opt/local/etc/dovecot
sudo cp /opt/local/share/doc/dovecot/example-config/dovecot.conf .
sudo cp -r /opt/local/share/doc/dovecot/example-config/conf.d .

Some file editing (use sudo nano ...), with < the edits you need to make:

10-mail.conf:

30c30
< mail_location = mbox:~/mail
---
> #mail_location =

10-ssl.conf:

6c6
< ssl = no
---
> #ssl = yes
12,13c12,13
< #ssl_cert = </etc/ssl/certs/dovecot.pem
< #ssl_key = </etc/ssl/private/dovecot.pem
---
> ssl_cert = </etc/ssl/certs/dovecot.pem
> ssl_key = </etc/ssl/private/dovecot.pem

auth-system.conf.ext:

14c14
<   args = login
---
>   #args = dovecot

Finally, register and start the new service:

sudo launchctl load   -w /Library/LaunchDaemons/org.macports.dovecot2.plist

At this point, create a new “mail” directory in your home directory and a bunch of empty files for each IMAP folder, simply connect with IMAP on local host with your account’s user name and password, and you’re good to go.

Published on August 20, 2012 at 21:29 EDT

Older post: Streaming Music Week - Recap

Newer post: Really Secure Online Storage