Monday, January 9, 2012

Liberate your mail for great justice.

Internet Folks-

Fear moving your mail no longer! I have traveled across the vast Internet desert and found a solution to cure what ailes you, moving mail between servers. I present to you:

mbsync

mbsync is part of the isync package for synchronizing imap accounts through the use of a simple configuration file (defaults to ~/.mbsyncrc).

Configuration

IMAP is pretty flexible and so the configuration file allows you to tune mbsync to traverse your inbox hierarchy. The important thing is to get yourself logged in. I’ve found mbsync -lV channel to test accessing channel a useful debugging technique.

If you don’t want to use secure login for an account, under your IMAPAccount entry make sure you have the following:

UseTLSv1 no
RequireSSL no

This will send passwords in the clear

The following should serve as a fairly complete example for common IMAP setups:

IMAPAccount example
Host example.tld
User example

IMAPStore example-remote
Account example
Path INBOX.

MaildirStore example-local
Path ~/Maildir/
Inbox ~/Maildir/Inbox

Channel example
Master :example-remote:
Slave :example-local:
Patterns *
Create Slave
Expunge Slave
Sync Pull

Group example
Channel example:INBOX
Channel example

The above grabs the inbox and anything under INBOX and stores it in ~/Maildir/. The Channel, Group, IMAPAccount can share a common name.

Usage

 $ mbsync example

That’s it, you can even add multiple accounts and put the mail in different places! Staring at the example and the man page should fill any gaps I’ve left out.

It really is that easy. So no longer worry about moving mail and just move it.

-Sean

Notes

  1. sean-bryant posted this