Ok, micro-howto:
1. We need to install 'imapsync'. I think, you can install it on any computer (source-mail-server, target-mail-server or your-workstation) - not on all, but on one of them. During setup you will facing with troubles with perl modules installing. But I can advise you setup Webmin and use it for installing perl modules - it can be useful at this time and for your future needings. But, IMHO.
2. You must prepare accounts on target server. I think it will be very useful to create accounts on target server with the same passowrds (like on old server). Thus you will reduce config troubles in the future steps. And, by the way, you reduce migration troubles with setting up email clients.
3. Examples 'how-to use imapsync' you can take from 'http://www.linux-france.org/prj/imapsync/README'. The mail idea is:
# imapsync --host1 server1 --user1 user1 --password1 password1 \
--host2 server2 --user2 user2 --password2 password2
All options are clear!
You can prepare two files with passwords and command above become:
# imapsync --host1 server1 --user1 user1 --passfile1 /etc/secret1 \
--host2 server2 --user2 user2 --passfile2 /etc/secret2
or
# imapsync --host1 server1 --user1 user1 --passfile1 /etc/secret \
--host2 server2 --user2 user2 --passfile2 /etc/secret
, if you created accounts with the same passwords!
As you may see, imapsync can use external sources (like files). But you can build bash scripts for read file with account names, passwords etc. For small example you cat read this one: http://extmemory.blogspot.com/2009/10/imapsync.html
I want pay your attention to option '--noauthmd5':
# imapsync --noauthmd5 ...
You can use this option if your mail servers do not allow MD5-passwords.
I've tested only method with secret files (see above) because I have several emails. Please post your experience in using 'imapsync' - you can help a lot of people migrate from different email servers to Dovecot
So, good luck!