Quick and dirty, still need to test it.
imapsync --host1 SOURCE_URL_OR_IP --user1 --password1 host2 DESTINATION_URL_OR_IP --user2 --password2
Next you will see how a simple command is written.
My source is hosted at mail.website.tld and has a mailbox with username “firstname.lastname@example.org” and password “macaroni”
Now I don’t want my client to have any troubles with having to enter a new password and such, so I set up the mailbox on the new server with the exact same data.
The new server has the IP address “111.222.333.444” and has been set up that the new mailbox is using the same credentials.
Your command will now look like this:
imapsync --host1 mail.website.tld --user1 email@example.com --password1 macaroni --host2 111.222.333.444 --user2 firstname.lastname@example.org --password2 macaroni
A lot of text will fly by now and you will see that the mailboxes are synching. If you get “Detected 0 errors” at the end, all went well.
Now proceed with the other mailboxes and then you can make the change in the DNS to make the mailboxes on your new server available.