imapcopy is a script and Perl module for quickly copying all messages and folders from one IMAP account to another.