Moving email from one IMAP server to another

muttlogoAh, the power of tools! What do you do when you want to move lots and lots of email between two IMAP servers? Sure, you could open them both in Thunderbird and drag-and-drop messages. It would simply take forever and you would be transmitting messages first to your computer and then back to another server. And Thunderbird has a bad habit of timing out. There is a better way.

Login to the server (or you can do it actually from client if transferring back and force is okay). Get mutt. Then open the source mailbox like this:

mutt -f imaps://albert%40example.com@imap.gmail.com/%5BGmail%5D/All%20Mail

and wait for mutt to load the headers of the email. Once it is ready, select all messages by pressing T and entering ~A. Save the messages to your target server by pressing ;s (if you want to move the mail) or ;C (if you want a copy) and giving the destination IMAP server:

imaps://albert%40example.com@mail.example.com/INBOX

And watch the magic of UNIX tools unfold :)

Leave a Reply

Your email address will not be published. Required fields are marked *