I am in the process of switching IMAP providers because the one I have been using for the last ~10 years, FastMail, decided to jack up the price and I could barely justify the old price. Furthermore, I want to get my own family on to private/custom email and it would be absurd to pay FastMail’s price 5x.
Anyways… so how to best move the 70k emails from FastMail to my new provider?
I remembered using offlineimap in the past for doing backups and it turns out it’s perfectly suited to sync messages from one IMAP server to another.
To start I had to get the SSL/TLS certs for the servers and put them in a PEM file,
$ echo \ | openssl s_client \ -CApath /etc/ssl/certs \ -connect imap.fastmail.com:imaps \ -showcerts \ | perl -ne 'print if /BEGIN/../END/; print STDERR if /return/' \ > offlineimap.pem $ echo \ | openssl s_client \ -CApath /etc/ssl/certs \ -connect mail.privateemail.com:imaps \ -showcerts \ | perl -ne 'print if /BEGIN/../END/; print STDERR if /return/' \ >> offlineimap.pem
Then I created an
[general] accounts = Sync [Account Sync] localrepository = Destination remoterepository = Source [Repository Source] type = IMAP remotehost = imap.fastmail.com remoteuser = email@example.com remotepass = REDACTED folderfilter = lambda foldername: foldername in ['Archive'] sslcacertfile = offlineimap.pem starttls = no [Repository Destination] type = IMAP remotehost = mail.privateemail.com remoteuser = firstname.lastname@example.org remotepass = REDACTED sslcacertfile = offlineimap.pem starttls = no
Finally, I ran,
$ offlineimap -c offlineimap.conf
which was safe to re-run later when there are new messages to sync over.