In order to copy mail from mail mailbox to another via IMAP
FIrst install IMAPCOPY from git
https://github.com/imapsync/imapsync.git
Follow instruction from readme
copy mailboxes./imapsync --host1 hostname --user1 user@domain.tld --password1 'xxxxxx' --host2 hostname --user2 user@domain.tld --password2 'xxxxx' --debug
Watch out for open/closed port at Firewall
also --authmech2 LOGIN --notls --nossl options can be tricky