imapcopy is a program to copy mails from one IMAP mailbox to another. I was using this for email migrations.