Use larch to migrate the data stored in a user’s IMAP account.

To install it on Debian/Ubuntu:

# apt-get install larch

When executing larch, it will prompt the source and destination email and passwords

EXAMPLES:

Copy INBOX folders from example.com to gmail.com

# larch --from imap://mail.example.com --to imap://imap.gmail.com

Copy all folder from example.com to gmail.com excluding the folders Spam and Trash

# larch --from imap://mail.example.com --to imap://imap.gmail.com --all --exclude Spam Trash

Copy all folders from example.com to gmail.com using SSL

# larch --from imaps://mail.example.com --to imaps://imap.gmail.com --all