Thursday, September 3, 2009

Migration to Gmail

Two days ago I successfully migrated two e-mail accounts to Gmail, one university e-mail and one department e-mail. Both of them are Unix based, and the IMAP server stores all mails except the INBOX in my home directory. Here is what I did.
  • Create a new Gmail account. It will hold both the university and department e-mails.
  • In my home directory, create a .forward file that contains the new Gmail e-mail address, and remove (or rename) the .procmailrc file.
  • Enable IMAP in Gmail.
  • Migrate old e-mails (I have about one year's worth kept in the mailbox) using imapsync. The university account runs UW imapd, and the department runs Dovecot. Here are the specific arguments to imapsync (besides login credentials) and why I needed them.
    • --folder INBOX (to specify the inbox folder)
    • --folderrec mail (this is the directory where all the mails are stored in Pine)
    • --prefix1 mail/ (mailboxes with this prefix are stripped by imapsync)
    • --regextrans2 's,Sent Messages,[Gmail]/Sent Mail,g' (I had used Apple Mail with these accounts too, and Apple Mail saves the sent e-mail in the Sent Messages folder, so I configured pine to do the same; now I want these to go under Gmail's Sent Mail folder)
    • --regextrans2 's,spams,[Gmail]/Spam,g' (I kept a separate spams folder; could have removed this folder before the migration).
    • I should have done this too: --regextrans2 's,INBOX,label-name,g' (the INBOX of each account goes under a different label). I simply did this manually after the fact which was a lot of work.
  • imapsync prior to 1.288 wants to download the list of all folders regardless whether you need them or not. This means the imap server will traverse all the files in my home directory, and this takes a lot of time. Version 1.288 solves this problem by only enumerating all folders when you use the --include option. I temporarily changed line 915 in imapsync as follows:
    -my @all_source_folders = sort $from->folders();
    +my @all_source_folders = sort $from->folders($prefix1);
  • When adding a new From e-mail in the Gmail account, they offer to setup an SMTP server. This eliminates the "From: on behalf of" message shown in Outlook.
  • I configured pine to access Gmail over IMAP as follows. I edited .pinerc to change the following settings:
    • inbox-path={}label-name (For each old e-mail I migrated, I tagged them with a dedicated label, so the inbox for Pine would show what was there before)
    • folder-collections=Main {}[] (This is so I can see e-mails under other labels)
    • default-fcc={}[Gmail]/Sent Mail
    • postponed-folder={}[Gmail]/Drafts
  • Lastly, I created filters to tag and archive incoming e-mails and then used the multiple inbox Gmail lab feature to be able to see e-mail coming in from both accounts at once.

No comments: