You may need to migrate email boxes or even entire mail servers that use different email storage formats like Mailbox and Maildir , which are incompatible or extremely difficult candidates for a raw migration by simply moving files from one folder to another while working at the filesystem level. Alternatively, you may simply want to migrate the contents of a mailbox (perhaps a free one like Gmail) to your new domain.
The best, most professional and high-performance solution is to use the IMAPSYNC tool which, working from the command line, allows you to perform an incremental migration from mailbox A to mailbox B in a completely painless way.

This tool, which can be found at http://freshmeat.net/projects/imapsync/ and is available for Windows and Linux systems, can be installed extremely easily via apt for Debian and derived systems and yum for derived Redhat systems.
Prerequisites
In addition to downloading and correctly installing the tool, one of the fundamental prerequisites is also IMAP access to both the source and destination mailboxes .
If you don't have IMAP support on even one of the two, try to talk to your provider to enable the IMAP protocol that responds on the default port 143. In some rare cases, the IMAP protocol could be an additional value-added service, in most cases, a feature enabled by all hosting providers and email service providers.
Obviously you will also need to know the IMAP parameters of the source server, the destination server and the credentials of the respective source and destination boxes, i.e. username and password.

To be clear in short, you must have all the data (the same identical) that you would use if you were configuring your e-mail account on one of the mail clients such as outlook, mail for MacOS or any other you want.
Its use is quite basic : basically you need to pass it the data to connect to the server from which to copy and then the data of the server to which the emails are to be copied.
Syntax and operation.
The command line syntax is concerned with essentially specifying the host name and credentials for both the source and destination servers.
An example is the following:
imapsync --host1 SERVER_ADDRESS1 --user1 USER_1 --host2 SERVER_ADDRESS2 --user2 USER_2 --authmech1 PLAIN --authmech2 PLAIN --noauthmd5 --ssl2
Obviously you will have to replace some parts above:
SERVER_ADDRESS1 is the IP address or hostname of server number 1
SERVER_ADDRESS2 is the IP address or hostname of server number 2
USER_1 is the user on server number 1
USER_2 is the user on server number 2
The script will ask you for the passwords of the two users, after which the synchronization will begin.
The –ssl2 parameter is necessary as PLAIN authentication is usually only allowed on the ssl encrypted channel.
imapsync has the advantage of synchronizing servers incrementally , files already synchronized are no longer moved allowing for less time in case of subsequent synchronizations.
Among the available options we can indicate whether to use an ssl connection, exclude messages that are too big or too old and / or exclude entire directories.
Be careful to always match the source and destination e-mails, and to correctly enter the e-mail credentials on the source and destination account (which could generally be different: normally the passwords are first set all the same, both originally than in destination, to do first).
If you have difficulty using this tool, you can opt for outsourcing consultancy and contact us directly at our address https://managedserver.it/supporto