Skip to content

Migrate Maildir to Gmail

Recently it was time to refurbish our email infrastructure. For a very long time I was hosting everything for myself, but things don't get easier and over time even the spam filters couldn't catch up. Therefore I looked into a number of hosted services, and in the end settled with Google Gmail.

 

End of last year I ran a test, migrated one of my domains over to Gmail and tried out if Gmail offers all the required functionality. As with every change, not everything works flawlessy, but mostly I found ways to get things working. As example we have different domains, several users, multiple identities (one per domain), other servers (like a webserver) can create emails as well (needs to play well with SPF and DKIM), a number of different email programs, mobile support and more.

Pro tip: if you run a test with Gmail and close the account before they charge you, you not only have to cancel the service, you also have to close the account. Else the domain is still associated with the test account.

For my wife it was mostly moving the emails in Thunderbird from one account to another, and create new identities. For me it is a bit more complicated, as I was previously relying on a combination of mutt, synced emails between two servers using unison, and sending emails from my laptop. This setup was not very mobile friendly, and a number encrypted emails didn't made things easier. Did I mention that it was time to overhaul everything?

Many years back I switched from the not very friendly Mbox format to Maildir format. This comes handy if mails are to be synced between multiple servers (unison), but doesn't play well with IMAP. Therefore I needed a way to import the Maildir folders into Gmail.

Scott Yang wrote a script named maildir2gmail.py, which I tried out last year, and added more features. Mostly the flag for handling unread emails, and create folders in IMAP on the fly. The script itself keeps track which emails are already copied, therefore it can be interrupted at any time, and will continue when restarted. Very handy, because I have gathered quite a number of emails over the years ...

After enabling "less secure apps" in Gmail, and creating an account just for the import, I ran the following two commands for every Maildir folder:

for dir in maildir1 maildir2 dir/maildir3 dir/dir/maildir4
do
    echo "Directory: $dir"
    python maildir2gmail.py -f "transfer/$dir" -u <account> -p <password> -n "mail/$dir/new"
    python maildir2gmail.py -f "transfer/$dir" -u <account> -p <password> "mail/$dir/cur"
done

This will create a new subdirectory under the "transfer" IMAP folder, and copy unread and read emails into this folder, using the appropriate flag. By using a "transfer" folder I did not directly mix all new emails into the existing folders/labels, but gave myself a chance to move them around as I wish, once the upload was complete.

  • Twitter
  • Bookmark Migrate Maildir to Gmail at del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • Digg Migrate Maildir to Gmail
  • Bloglines Migrate Maildir to Gmail
  • Technorati Migrate Maildir to Gmail
  • Fark this: Migrate Maildir to Gmail
  • Bookmark Migrate Maildir to Gmail at YahooMyWeb
  • Bookmark Migrate Maildir to Gmail at Furl.net
  • Bookmark Migrate Maildir to Gmail at reddit.com
  • Bookmark Migrate Maildir to Gmail at blinklist.com
  • Bookmark Migrate Maildir to Gmail at Spurl.net
  • Bookmark Migrate Maildir to Gmail at Simpy.com
  • Bookmark Migrate Maildir to Gmail at blogmarks
  • Bookmark Migrate Maildir to Gmail with wists
  • wong it!
  • Bookmark using any bookmark manager!
  • Stumble It!
  • Identi.ca

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
To leave a comment you must approve it via e-mail, which will be sent to your address after submission.
Form options