ServersUse OfflineIMAP to Sync Email on the Go

Use OfflineIMAP to Sync Email on the Go

ServerWatch content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.




Mail is the lifeblood of system administrators. Having a great, not good, mail system in place is key to being productive in many cases. If you can escape the corporate horror of Microsoft Outlook and use a more capable client like Mutt, you can be much more productive. One of the support tools I depend on for productive use of Mutt is OfflineIMAP

Having a working email system in place is key to the lifeblood of most system
administrators. Those looking beyond Outlook will find much to like in Mutt,
particularly OfflineIMAP, whose functionality is exactly as its name implies.

What is OfflineIMAP? The name says it all, really. I turned to OfflineIMAP for two reasons. One, I needed a good way to download mail from Gmail. Second, I decided to start using Mutt again to streamline my mail processing and Gmail’s interface just wasn’t cutting it.

Technically, Mutt does do IMAP, but I’ve found it to be very slow. OfflineIMAP is relatively speedy. Plus, you know, it does give the benefit of allowing you to process mail offline, far away from the loving embrace of a network connection. This means if I want to slog through a backlog of email without distraction, I can slurp down my email, head to my favorite coffee shop and slam through my mail with a good cup of coffee.

Most Linux distributions and BSD flavors should have OfflineIMAP packages. If not, or if you just want to grab the latest, see the source repo at Github. Note that the maintainership has transferred from John Goerzen to Nicolas Sebrecht as of November 2010, despite many of the Google results still pointing to Goerzen’s repo.

Once installed, OfflineIMAP is very easy to configure. Let’s take a look at my configuration:

[general]
accounts = accountname
maxsyncaccounts = 3
socktimeout = 60

ui = TTY.TTYUI

[Account accountname]
localrepository = local
remoterepository = remote

[Repository local]
type = Maildir 
localfolders = /home/user/Mail

[Repository remote]
type = Gmail
remotehost = imap.gmail.com
remoteuser = user@domain.tld
remotepass = XXXXXXXXXXXXXX
ssl = yes
realdelete = no

OfflineIMAP supports Gmail IMAP and regular IMAP because Gmail’s IMAP is “special,” which
is to say “it doesn’t seem to work exactly like IMAP should.” But OfflineIMAP
seems to work flawlessly with it, so let’s continue. Replace “Gmail” with IMAP
if you have a standard IMAP server. The type is a choice between IMAP and Maildir.
Why IMAP? You could choose to sync mail from one IMAP server to another. For
example, you might want to use OfflineIMAP to sync Gmail into your company’s
IMAP server or a personal IMAP server. I use it to store mail in a Maildir
folder for better Mutt compatibility, though. Unfortunately,, Mbox is not supported.
The maintainers have said they would take Mbox code if it was offered, but
so far nobody seems to have offered …

The rest of the config should be straightforward, just edit to fit your tastes. Now you just need to save this as ~/.offlineimaprc and run offlineimap. If you’re using Mutt or another reader that supports Maildir, you should be able to point them at the mail directory and start reading.

For more complex setups, take a look at the sample configuration. You can tweak many settings like the maximum age of mail to keep, the path to your SSL Client cert/key to verify the SSL server (otherwise it’s not verified), the maximum number of connections to use, and so on. OfflineIMAP is very mature, and if there’s something you think it should do, it probably does.

OfflineIMAP, combined with Mutt and msmtp, has made reading and responding to mail much more efficient for me. If you’re struggling with mail, you might want to spend some time looking into OfflineIMAP.

Joe ‘Zonker’
Brockmeier
is a freelance writer and editor with more than 10 years covering IT. Formerly the openSUSE Community Manager for Novell, Brockmeier has written for Linux Magazine, Sys Admin, Linux Pro Magazine, IBM developerWorks, Linux.com, CIO.com, Linux Weekly News, ZDNet, and many other publications. You can reach Zonker at jzb@zonker.net and follow him on Twitter.

Follow ServerWatch on Twitter

Get the Free Newsletter!

Subscribe to Daily Tech Insider for top news, trends & analysis

Latest Posts

Related Stories