The easiest way to transfer email to another server is via SSH access using imapsync. You can install it on your VPS either from the repository or from the following link: http://imapsync.lamiral.info/.
To perform the transfer, you will need:
Start the synchronisation with the following command (using your own values, of course):
imapsync --host1 server1 --user1 email1_username --password1 email1_password --host2 server2 --user2 email2_username --password2 email2_password
Example command: in the example below, we synchronise the emails in the mailbox info@domena.si on the server Rebeka with the same mailbox on the server Klara:
imapsync --host1 rebeka.zabec.net --user1 info@domena.si --password1 geslovida --host2 klara.zabec.net --user2 info@domena.si --password2 geslonika