how to migrate imap account(s)

I recently had to change my website/mail provider, of course I also wanted to move my mails from one mailaccount to the other. With the Mac’s native email client I wasn’t very pleased dealing with this task, so my final solution for this is imapsync.

I just had very few accounts to migrate (two) so the commands for this were quite straightforward:

imapsync --host1 old_providers_host --user1 oldaccount --password1 oldpassword --port1 993 --ssl1 \
--host2 new_providers_host --user2 newaccount --password2 newpassword --ssl2 \--justfolders --dry "$@" --timeout 20 --delete2duplicates

The port setting were actually different and I had to explicitly activate SSL, but than it worked nicely. With the --dry option it just connects and does not really copy anything. I also liked to set the timeout lower, so that it fails quicker. Also to ensure I have no duplicates in my new home I added the last option.

After successful connection and testing I removed the options (--justfolders --dry "$@" --timeout 20) and let it copy the mailboxes.