Our internet connection from home is somewhat flaky, and long-running connections are often dropped. This is not usually a problem, I just make liberal use of screen when using SSH. The dropped connections are annoying when I'm reading my mail over IMAP with mutt, my prefered mail client. Mutt caches many changes (marking messages as read, deleting messages, etc.) and only pushes the changes to the remote IMAP server periodically. If the connection drops before Mutt pushes those changes, your changes get lost, and you have to reconnect and work through the mail again.

It would be nice if I could work through my mail locally, and use a more robust tool to deal with the networking side of things. There are a number of tools to accomplish this, including the vernerable fetchmail, but I use OfflineIMAP because it allows me to store my mail locally while retaining direct IMAP access if I need it (e.g. using webmail from an internet cafe).

Install (on Gentoo) with

# emerge -av net-mail/offlineimap

If you're running Python >= 2.7.2rc1 you'll need OfflineIMAP >= 6.3.3 to avoid problems such as Unknown IMAP4 command: 'file'.

Then create ~/.offlineimaprc following the provided examples. To sync my Drexel account with my local machine, I use something like:

[general]
accounts = Drexel

[Account Drexel]
localrepository = DrexelLocal
remoterepository = DrexelRemote

[Repository DrexelLocal]
type = Maildir
localfolders = ~/mail/drexel
sep = /

[Repository DrexelRemote]
type = IMAP
ssl = yes
remotehost = imap.mail.drexel.edu
remoteuser = REDACTED
remotepass = REDACTED

Then run offlineimap to start the bidirectional syncronization. With the configuration above, you'll need to drop OfflineIMAP into a cron job (or just run it before you want to read your mail, and again after you've made any local changes).

If you want to run OfflineIMAP continuously as a daemon, take a look at the autorefresh configuration option.