How to migrate mailbox between IMAP Servers with imapsync

imapsync software is a command line tool allowing incremental and recursive imap transfers from one mailbox to another, both anywhere on the internet or in your local network.

imapsync is useful for imap account migration or imap account backup.

imapsync is not adequate for maintaining two active imap accounts in synchronization where the user plays independently on both sides. Use offlineimap (written by John Goerzen) for this purpose.


First, create same mailbox on the new mail server.

Then, install imapsync on CentOS: (It doesn’t matter where we install imapsync – we can even install it on a third server.)
yum install imapsync

I’ll use the following data for migration
Old mail server:
New mail server:
Old mailbox:
New Mailbox:
Save old mailbox password in file: /etc/mailpass1
Save new mailbox password in file: /etc/mailpass2

Migrate the old email in on server mail1 to the new mailbox on server mail2:
imapsync --host1 --user1 --passfile1 /etc/mailpass1 --host2 --user2 --passfile2 /etc/mailpass2

2 thoughts on “How to migrate mailbox between IMAP Servers with imapsync

  • Thursday June 2nd, 2011 at 19:49


    Postfix is a SMTP server, there is no “Postfix mailbox”. You have to detect the IMAP server holding mailboxes. Postfix delivers messages to an IMAP server via a deliver agent. Postfix doesn’t know it deliver to IMAP or POP or file or command. The title is wrong, the body is good.

  • Saturday June 4th, 2011 at 21:21

    Hi Gilles,

    Thanks for pointing out my mistake! I was trying to add more keywords to the title. 🙂

    I came across your website and found the Imapsync utility really helpful. so excited to see you here.


Leave a Reply

Your email address will not be published. Required fields are marked *