Larch is an alternative to imapsync that works just as swimmingly. With a working Ruby environment, installation is as simple as:
gem install larch
To migrate dozens of mailboxes from one server to another, you might create a script that looks something like:
#!/bin/bash
# pullmail.sh
function pullmail {
larch \
--all \
--from imaps://source.example.com \
--from-pass "$2" \
--from-user "$1" \
--max-retries 20 \
--to imaps://dest.example.com \
--to-pass "$2" \
--to-user "$1"
}
PS4='\t+ '
set -x
pullmail alice password1
pullmail bob password2
[…and so on…]
Then you might run it with: ./pullmail.sh 2>&1 >> pullmail-$(date +%Y%m%d%H%M).log &
. Once complete, you can review the log to address any email that might have had trouble syncing. With luck, all the mail in every folder and in every account will have been copied from the old server to the new.
Also, Larch is smart enough to keep track of what mail it has already synced, so it is safe to re-run the sync again and again until you are satisfied.
You’ll want to consult the documentation to fully understand what is going on. There is also a support forum in case you run into any issues.