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: mail1.mazentop.com
New mail server: mail2.mazentop.com
Old mailbox: firstname.lastname@example.org
New Mailbox: email@example.com
Save old mailbox password in file: /etc/mailpass1
Save new mailbox password in file: /etc/mailpass2
Migrate the old email in firstname.lastname@example.org on server mail1 to the new mailbox email@example.com on server mail2:
imapsync --host1 mail1.mazentop.com --user1 firstname.lastname@example.org --passfile1 /etc/mailpass1 --host2 mail2.mazentop.com --user2 email@example.com --passfile2 /etc/mailpass2