My guess is you already have plain,login authentication support at both ends.
1. You will need the root user password of both the systems for the following command to work.
2. Plain, login authentication support at both ends. (In most cases plain is enough I think)
3. There is no need for the username to be same at the two ends. i.e you can migrate jack's mails to jenny's mailbox
Do a dry run first for checking: (in a single line)
imapsync --syncinternaldates --subscribe --host1 192.168.1.100 --host2 192.168.1.20 --user1 jack --authuser1 root --password1 google --user2 jenny --authuser2 root --password2 yahoo --noauthmd5 --dry
If it runs correctly then let her rip,
imapsync --syncinternaldates --subscribe --host1 192.168.1.100 --host2 192.168.1.20 --user1 jack --authuser1 root --password1 google --user2 jenny --authuser2 root --password2 yahoo --noauthmd5
host1 192.168.1.100 --> mailserver that has jack's mailbox
host2 192.168.1.20 --> mailserver that has jenny's mailbox (i.e destination)
authuser1 --> host1's root user & --paswd1 host1's root user password
authuser2 --> host2's root user & --paswd2 host2's root user password
noauthmd5 --> Don't use md5 based authentication mechanisms i.e cram-md5 or digest-md5. So only, we need plain or login mechanisms, after migration you can revert back to using cram-md5, digest-md5 or other auth mechanisms,
syncinternaldates --> make sure the timestamps are preserved
subscribe --> subscribe the imap folders in the original mailbox