Cristi - blog


Migrate IMAP accounts

The first assumption here is that you have a bunch of IMAP mailboxes and you want to migrate them to another IMAP server. The second is that the old server is still up and running.

The low tech approach would be dragging and dropping from one server to another using your mail client. But that's not feasible in our scenario. So if you want to keep the mailboxes, you will have to use something like imapsync, which is a command line tool that allows incremental and recursive IMAP transfers from one mailbox to another.

The official page claims compatibility with 62 different imap servers. It should also be noted that imapsync is under the WTFPL (Do What the Fuck You Want to Public License). This license is listed on gnu.org as "... a free software license, very permissive and GPL-compatible". Gilles Lamiral happens to require payment if you want a copy of the latest code from his site, but the terms of his license allow further redistribution.

Here's an example of migrating a mailbox from Domino IMAP4 Server Release 8.5.3FP3 to a Courier IMAP server using imapsync 1.607 (after test@example.com was also created on the new server):
imapsync --buffersize 8192000 --nosyncacls --subscribe --syncinternaldates \
--host1 oldserverip --user1 test@example.com \
--passfile1 /home/cristi/secret1 --ssl1 --port1 993 --authmech1 PLAIN \
--host2 newserverip --user2 test@example.com \
--passfile2 /home/cristi/secret2 --ssl2 --port2 993

imapsync will run faster and consume less CPU with larger I/O buffers. --nosyncacls does not synchronize acls. Acls in IMAP are not standardized. --subscribe is used to... subscribe to the folders transferred on the host2 that are subscribed on host1. --syncinternaldates will set the internal dates (arrival dates) on host2 same as host1. You can use SSL connections by specifying --ssl1 and/or --ssl2 (and --port1 and/or --port2 if defaults are different) for each of the accounts you wish to migrate. To avoid timeouts, you can also add --nofoldersizes --skipsize --fast

Since there are lots of mailboxes to migrate, think about writing a little shell program. And feel free to hack imapsync as the "nolimit" license permits it. One thing I love about this tool is that you can use it for liberating mailboxes from proprietary formats, such as the "Notes Storage Facility" used by the dreadful IBM Domino mail server.

Posted 20 November 2014.

← Previous: GNU Chess and XBoard


Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.