We recomend that you use a tool such as imapsync from freshmeat.net.
imapsync is a tool for facilitating incremental recursive IMAP transfers from one mailbox to another. It is useful for mailbox migration, and reduces the amount of data transferred by only copying messages that are not present on both servers. Read, unread, and deleted flags are preserved, and the process can be stopped and resumed.
The original messages can optionally be deleted after a successful transfer.
An alternative solution that doesn't involve imapsync is at the foot of the article.
imapsync is the adequate tool because it reduces the amount of data transferred by not transferring a given message if it is already on both sides.
Same headers, same message size and the transfer is done only once. All flags are preserved, unread will stay unread, read will stay read, deleted will stay deleted. You can stop the transfer at any time and restart it later, imapsync is adapted to a bad connection. imapsync is CPU hungry so nice and renice commands can be a good help. imapsync can be memory hungry too, especially with large messages.
You can decide to delete the messages from the source mailbox after a successful transfer (it is a good feature when migrating). In that case, use the --delete --expunge1 options.
You can also just synchronize a mailbox A from another mailbox B in case you just want to keep a "live" copy of B in A.
To get a description of each option just run imapsync like this :
The option list :
imapsync [--host1 server1] [--port1 <num>]
[--user1 <string>] [--passfile1 <string>]
[--host2 server2] [--port2 <num>]
[--user2 <string>] [--passfile2 <string>]
[--authmech1 <string>] [--authmech2 <string>]
[--folder <string> --folder <string> ...]
[--folderrec <string> --folderrec <string> ...]
[--include <regex>] [--exclude <regex>]
[--prefix2 <string>] [--prefix1 <string>]
[--regextrans2 <regex> --regextrans2 <regex> ...]
[--justfolders] [--justfoldersizes] [--justconnect]
[--regexmess <regex>] [--regexmess <regex>]
[--useheader <string>] [--useheader <string>]
[--expunge] [--expunge1] [--expunge2]
[--timeout <int>] [--fast]
A simpler alternative method is to create a new mailbox and configure it on the same email client that you use for your current mailbox. Ensure that you select IMAP as the mailbox type during configuration. A list of configuration guides are available here.
Once setup, drag and drop mail from your old mailbox to a folder on your new mailbox. Any email copied across will be uploaded to our servers.