I do recommend Official imapsync migration tool ( release 2.290 )
And then use it like this (your desired options may vary):
./imapsync --host1 old.server.name --user1
[email protected] --password1 'P4sSw0rd' --host2 new.server.name --user2
[email protected] --password2 'P4sSw0rd' --automap...