Move/Copy mails between different IMAP accounts

Posted on Sat 15 November 2014 in tech

I decided to switch back to Gmail/Inbox by Gmail. Copying thousands of mails in Thunderbird is a pain and after a couple of unsuccessful tries I started to search a better working alternative. mutt to the rescue!

# login to your old imap account:
mutt -f imaps://username@oldmailserver/INBOX/folder
# mark all messages in that folder (otherwise use "t" to select single messages)
enter "T" and then "~A" 
# either copy (;C) or move (;s) the messages. ;s will mark them as deleted on the old account!
enter ";C"
# as a target directory choose your gmail account:

You may want to start mutt in a "screen" session and then let it run for a while. On linux systems mutt should already be installed. On OSX you can find it in homebrew.