Exporting large Gmail mailboxes with imap-upload

A safe, simple way to shift a shit ton of email

I’ve been working on moving away from gmail, for a number of reasons. The primary one being that I don’t want to live under the gmail.com domain anymore - I’d much rather have my own.

The main issue for me was - how do I shift all my emails to a new server (or service, in my case)?

There are imap sync services and programs out there but gmail limits the rate at which you can export stuff. It’s a shame, because going server-to-server makes sense otherwise. If you have a smaller inbox (less than 10k emails) I would do this instead. Look into imapsync.

I have 120k emails, so I needed a better solution.

Initially I tried a ‘move’ operation in Thunderbird but it crashed at about 3000 emails in, which already took quite a while. I like the software but I’m not sure it’s fit for purpose for shifting this amount of stuff.

What I did was simple:

  • Used Google Takeout to download an mbox file of all my emails.
    • This took a while to prep but it’s pretty hands off. The resulting file was a 1.5GB download that was 4GB uncompressed.
    • Google emails you a link to the download when it’s ready. Took a few hours for me.
  • I then used a tool called imap-upload to upload the emails into my new service.
    • I just uploaded them all to an ‘Archive’ folder but you can be more specific if you want.

Simple as that! The command I ran was:

python imap_upload.py foo.mbox imaps://username:password@imap.newhost.com/Archive 

I have a good internet connection but a slow PC, and it uploaded all 120k emails in a few hours.