Switching to Gmail

gmailOne of the things I had been meaning to do for some time was to switch all of my email over to my Gmail account. The idea is simple: I have a lot of different email accounts, and it’d be great to keep them all in one place, backed up, and always accessible. So, setting up Gmail to access each of my different email accounts (well, five of the most important, and the rest just forward to my gmail address) was trivial. The hard part, however, was getting all my previous messages into Gmail.

Here’s a quick overview of how to get all of your old emails into Gmail as painlessly as possible (and one way that preserves dates!).

Loading Emails
I spent some time looking into the different options I had for loading my email messages into Gmail. I have about 10 thousand or so that I wanted to keep stored (there’s a lot more than that sitting around in various mbox files, but these were the important ones). These 10 thousand or so messages comprised about one year of using the Apple Mail application on my Mac. So, poking around, I found a Python script by Mark Lyon called GML (for GMail Loader), which was designed to iterate through each message in an mbox (or other format) file and forward each message to GMail.

I managed to get the script working (one tip: be sure to export your messages by using the Save Archive option, which will create appropriately formatted mbox files for the script to read) and was able to import about the first thousand or so messages I had. Unfortunately, I ran into a couple of problems. First, I could only forward so many messages an hour due to a restriction set by my ISP’s SMTP server. Second, and most problematic, was that the GML script would actually forward each message, one-by-one, as if I were clicking the Forward button in my email client. This meant that, although the message still had it’s original date associated with it, the message would show up as having been originally sent on the date that I forwarded the message, not when it was actually received. This was a problem, and there had to be another way.

One idea I had was to setup my own pop server, where I would place all of my archived messages, and setup this server as an account in Gmail. Then, Gmail would connect to my mail server and load all of my old messages. I never got a chance to try it, but my guess is that it would work. Instead, another idea came up (courtesy of Costa): use IMAP.

Not long ago, Google announced the Gmail service would now support IMAP, allowing mail clients to connect to Gmail and use it as a kind of clearinghouse for all things email (IMAP stores everything on the server, allowing any number of clients to connect and always appear in sync with one another). If I added Gmail as an IMAP account to my Apple Mail program, could I then simply drag messages stored in the various folders into Gmail? The answer, luckily, was yes!

It was simple: I merely added Gmail as an IMAP account to my Apple Mail client, then just dragged folder-by-folder all the messages important to me onto my Gmail account. It took a while to transfer all the messages (be sure to open the Activity window in Mail to see your progress), but once it was done, all my old messages were safely stored in Gmail and had their original dates! Perfect!

Using IMAP
So now I’ve got my desktop Mail client using Gmail as my sole email account, along with my iPhone. Whenever I read a message on my desktop, it’s marked as read on my phone. And whenever I send an email from my phone, it appears in my Sent folder on my desktop. Everything stays in sync, and I’m very pleased with how it turned out.

One note: be sure to check out this page for details on fine-tuning your Gmail IMAP setup with Apple Mail and the iPhone. There’s a couple of neat little tricks to get your setup streamlined.

  • http://www.dracoware.com/blog/2007/12/10/12-notes-on-setting-up-gmail-imap-with-apple-mail/ 12 Notes on Setting up Gmail IMAP with Apple Mail » Draconis Software Blog

    [...] Just like Ryan, I’ve been in the process of moving to Gmail to handle all my email, now that they provide IMAP access. In no particular order, here are some notes and thoughts on the process of setting up Gmail IMAP with Apple’s Mail.app: [...]

  • http://www.techblogger.org/2007/12/11/import-messages-into-gmail-via-imap-gmail-tip/ Import Messages into Gmail via IMAP [Gmail Tip] · TechBlogger

    [...] not using Apple Mail, check out how to turn Thunderbird into the ultimate Gmail IMAP client. Switching to Gmail [Draconis Software [...]

  • http://www.cafeturk.net/import-messages-into-gmail-via-imap-gmail-tip.html/ » Import Messages into Gmail via IMAP [Gmail Tip]

    [...] not using Apple Mail, check out how to turn Thunderbird into the ultimate Gmail IMAP client. Switching to Gmail [Draconis Software [...]

  • http://jeffruday.com Jeff Ruday

    I have been searching for a while now for specific directions on how to do this. I currently have TB downloading all my Gmail, but only for back up. I do not use TB as my primary client, I use Outlook. My objective is to be able to create a mirrored Gmail account with the data in TB should I ever not be able to access my Gmail account. Because I do not use TB as my client I am not sure exactly how to “drag” the folders, or exactly which folders to drag. I am also concerned that if I test this method I may run the risk of accidentally deleting some of my Gmail data. I would be very grateful if you could provide the step by step method, possibly with some screen shots, so that I do not risk losing data. Thank you very much.

  • http://www.dracoware.com ryan

    @Jeff: So, if I understand correctly, you want archive all of the email that’s currently in ThunderBird into Gmail (i.e. messages stored in TB that were there before you setup your Gmail account)? If this is correct, then the idea is this: add your Gmail account to Thunderbird as a second account, using the IMAP protocol (instructions from Google are at http://mail.google.com/support/bin/answer.py?answer=75725), then drag+copy the email messages from your existing TB folders into the corresponding Gmail folders. To prevent losing any messages, be sure you COPY (not MOVE) your email messages.

    Sorry I can’t be more helpful, though, as I’m not using ThunderBird for email (just Apple Mail). Post any other questions you have though, as others may be able to help.

  • http://www.feedup.net/2007/12/12/import-messages-into-gmail-via-imap-gmail-tip/ Import Messages into Gmail via IMAP [Gmail Tip] teasered @ Feed UP !!

    [...] not using Apple Mail, check out how to turn Thunderbird into the ultimate Gmail IMAP client. Switching to Gmail [Draconis Software [...]

  • http://ImportingmessagesintoGmailfromTB Jeff

    @Ryan — Thanks for your note. Actually what I am attempting to do is create a “system” that will allow me at any time, to create a mirror image of my primary Gmail account, using the data that is synced daily between TB and my primary Gmail account. I already have on stand by a secondary Gmail account set up with labels and filters that mirror my primary account. This account is “empty” and is simply “standing by.”

    Should I ever be unable to access my primary Gmail account, I want to be able to immediately “upload” all primary Gmail account data stored in my local TB folders into my standby secondary Gmail account. This is my objective.

    As I do not use TB as my email client I am not all that familiar with its folder structure. I can see that TB has created a set of folders that mirror my primary Gmail labels. I also know how to create an additional TB user account and link it to my secondary Gmail account. What I DON’T specifically know how to do is: (1) drag the correct folders from one account to the other in TB, and (2) most importantly, protect the data in my primary Gmail account as I upload the local TB data into the secondary Gmail account.

    I have been studying this process for a while now, and the only think I lack is hands on experience with the folder copying step and the knowledge of how to make sure my primary Gmail data is preserved. Sorry to be so long winded. Thank you. Jeff

  • http://www.dracoware.com ryan

    @Jeff: Okay, I think I understand better now. I did something similar when I was experimenting with this IMAP setup, in that I had a secondary Gmail account where I would upload one message at a time from my local copy to see what would happen.

    What I suggest trying is to use your secondary account and copy over just one message. Start with that and see how it works. Consider sending yourself an email that you don’t care about, and experiment with it. Then, try dragging that email over to your secondary Gmail account, and see what happens. Did the email copy over? Did it get deleted from the first account? If you can answer those questions, then you’ll have a pretty good idea of what will happen when you actually copy over your real messages.

    One other thing: to keep your emails in sync with both Gmail accounts, I imagine you’re going to setup an “auto-forwarder”? You can do this using Gmail, where it will automatically forward every email that comes in to your secondary Gmail account. Then you won’t have to worry about copying messages over like this again: they’ll already be there.

  • http://ImportingmessagesintoGmailfromTB Jeff

    @Ryan: Thanks again. Two additional matters. I believe that when you use IMAP to download messages from Gmail the TB, the Gmail labels translate into TB folders. Do you agree?

    I use my primary Gmail account as my Getting Things Done (GTD) workspace, so I rely heavily on Gmail labels and filters. To be effective for me, I will need to create and maintain the secondary Gmail account with *exactly* the same labels and filters for all messages, initial and new.

    I understand that IMAP will allow me to initially create a second Gmail account that is a mirror image of my primary account. However I do not think the auto-forward process you suggest will allow me assign labels to a message before it is forwarded. The result of auto-forwarding messages therefore would not be consistent with the maintenance of a constantly mirrored site.

    Due to my extensive use of labels and filters it may not be possible for me to “maintain” a mirrored site. If possible that would be ideal, but my *goal* is just to be able to create a mirrored site (using local data in TB) in the unlikely event I am unable to access my primary Gmail account. I have read where this has happened.

    Finally, can you please explain in a little more detail the process of copying the folders from the primary Gmail account to the secondary Gmail account within TB? Do you “drag” the folders, c/p them … exactly how? Is this done in the “All Folders” panel of the TB main screen? Any chance we could exchange some “screen shots” to help me better understand how to actually do this task. I understand it, but not confident exactly how to do it.

    Thanks for your patience. Jeff

  • http://www.dracoware.com ryan

    @Jeff: First, yes: labels are treated as folders in IMAP (an email that appears in multiple folders means it has multiple labels).

    Second, to create that mirror Gmail account, yes: you would need to (painstakingly) recreate each label and filter, which can be quite a bit of work.

    Third, you’re right: you won’t be able to assign labels using the auto-forward, but if you setup your filters correctly on your mirror Gmail account, you can reapply those labels when it receives a forwarded email. So, on the mirror account, setup filters that check for keywords for each message to assign your labels to.

    Fourth, you may not be able to just do the forward/filter tip I suggested, due to your setup (if you do a lot of manual labeling, for instance). In that case, you’re options are to either relabel each item in your mirror Gmail account, or “just live with it” as a collection of lots of emails forwarded.

    And finally, for the process of copying, again: I don’t use Thunderbird and don’t know much about copying messages using it. But if it’s like Apple Mail, then you can do the following: select one or multiple messages, start dragging them to the destination Gmail folder, then press down the Command key (a green plus icon will appear, to indicate you’re COPYING, rather than MOVING, your messages), then drop those messages on that destination folder. I imagine Thunderbird is similar.

    Anyway, like I said, try copying just one message to start and seeing what happens. Also, I suggest you check out the ThunderBird community support sites (http://www.mozilla.org/support/#forums) for better information than I can provide. Hope this helps!

  • http://jeffruday.com Jeff Ruday

    @Ryan – Regarding your comment above:

    “Third, you’re right: you won’t be able to assign labels using the auto-forward, but if you setup your filters correctly on your mirror Gmail account, you can reapply those labels when it receives a forwarded email. So, on the mirror account, setup filters that check for keywords for each message to assign your labels to.”

    When you manually apply a label, does that process actually create a key word in that message? i.e. If I manually apply the label “dog” to an email, then forward that e-mail to my secondary e-mail account (which has a filter set to look for the word “dog”), will the secondary account apply the label “dog” to the forwarded e-mail when received?

    Thanks for you help thus far. I think I am close to being ready to give this a shot.

    Regards.

  • http://www.dracoware.com ryan

    @Jeff: No, labels don’t modify a message in any way. When you forward the email to your secondary account, it will need to search for key words in that email to apply the label. So this may not be possible, if you’re just manually applying labels to your messages.

  • Fer

    HI can you help me please. I would like to transfer all my mail from my mac to gmail. I followed the instructions for setting up a new account in apple for the gmail. However I am having problems. When I go to my folders and drag and drop the mail into the gmail inbox, it goes to the gmail account but then it also comes back to the gmail mbox on the mac. If I delete a message in the gmail mbox it also deletes the message in my actual gmail account . I think that two are synced. I am not very computer saavy and this has become a bit of a frustration, because I had loads of emails in my googlemail that all of a sudden started importing into mail, into the gmail inbox. So I deleted them from the gmail mail account on my mac and it also deleted them from my gmail account.
    Someone please help me, all I want to do is transfer all my mail to gmail easily and in a simple way that a novice can understand with clear step by step instructions. My mac has run out of space and I need to do something. I would be happy to talk to anyone on the phone.

  • http://www.hackcraft.net/ Jon Hanna

    5 years too late, but this is one of the pages that came up when I was trying to find something to make copying from some old POP3-downloaded mails to an IMAP account (not GMail, but the same applies).
    I found that copying to the IMAP within Thunderbird can be a bit flaky, and was poor at giving feedback; so I couldn’t be sure if it was working or not. http://imap-upload.sourceforge.net/ on the other hand was faster, more reliable (it retries on failure, and can also produce a new mbox file containing just those mails that failed, though such didn’t happen to me), and better at reflecting where it is. It’s command line, and requires you to find the mbox files yourself (with Thunderbird, the files in the mail directory with no extension are the relevant mbox files) but if you find yourself in the situation of having to upload a massive number of mails (which the recovery scenario of the solution Jeff wants would entail) then it will work nicely. It might also serve Fer well, depending on the mail client he was using and whether it uses mbox format (which a lot do).