Moving an email account (including old emails) from one cPanel server to another is pretty easy to do yourself if you have some knowledge of cPanel and FTP.
I will be using the terms OLD SERVER and NEW SERVER a lot in this article. Below are the definitions:
OLD SERVER = Server that the email account is currently on and will soon be moved from
NEW SERVER = Server that you want to move the email account to
Step 1: Create a new email account on the NEW SERVER with the same address and password.
You can do this by going into the cPanel on the NEW SERVER and click on Email Accounts.
Step 2: Download the files off of the OLD SERVER.
FTP onto the OLD SERVER and download the files needed. From the root directory, go to “mail/domain.com/emailAccount”. Here you will see a bunch of files. All you really need to copy are the new and cur directories.
If you have a lot of emails this could take a while.
Step 3: Transfer files to NEW SERVER.
When the files are downloaded in step 2 place the new and cur directories in the “root/mail/domain.com/emailAccount” of the respective account on the NEW SERVER. The folder should already be created since you already created the account in step 1.
Go get some coffee. This step will take awhile as well.
Step 4: Reset Mail Quota.
Now if you check the NEW SERVER you will see that your emails are transferred but your quota says 0/xxx MB. To update a wrong mail quota in cPanel: FTP to the OLD SERVER, open up the maildirsize file at “root/mail/domain.com/emailAccount” and copy all of the contents and paste them into the maildirsize file on the NEW SERVER.
You may have luck copying the maildirsize file on the OLD SERVER and pasting it on the NEW SERVER, however this did not work for me.
Step 5: Change DNS.
If you followed all of the steps up to this point you should have all the files transferred, but you still need to point your DNS records to the NEW SERVER in order to have mail go there. When you update your records it could take up to 24 hours to take effect.
Step 6: Test.
Finally, send a test email to the account. If that works, send an email from the account. You’re done!
By Keith Curreri on August 21, 2014 at https://buckleupstudios.com/easily-move-an-email-account-from-one-cpanel-server-to-another/
Or you could use IMAP protocol to migrate scripts through PHP script with bash like so: https://edoceo.com/dev/imap-move or use something more advance and full of features like: https://github.com/imapsync/imapsync