I currently use POP to access my gmail through thunderbird, but I would like to switch to IMAP so that my folders are mirrored on the server, and my sent emails are also available through the web interface.

The problem is that I have 1000s of emails in many different folders in Thunderbird, and in gmail, all my emails are in the same folder.

How can I perform the migration, and get all my folders from my POP access into Gmail?

  • 1
    Whatever you do, try to back things up before you switch. Reason: I did this quite a while ago (sorry, don't remember the details) and didn't like how things worked afterwards with IMAP and switched back to POP -- which was relatively easy because I had a backup to revert to. – martineau Jul 31 '11 at 15:27
  • For your bounty/bounties to be useful, you should really much expand your post with details of what you have tried and what doesn't work. You might also take this article which contains the official way of doing that, and explain what's wrong with this approach. – harrymc May 15 '13 at 9:01

Setup a new IMAP account in Thunderbird then simply drag&drop your folders from the POP3 account into the IMAP account.

  • This sounds like an incredibly good idea. Have you actually done it? – martineau Jul 31 '11 at 15:35
  • Also, this sounds like it could get tricky since there's only one Gmail account involved -- a pre-existing one with (presumably) messages already in it. – martineau Jul 31 '11 at 15:50
  • 1
    This is what I have gone with... and it does work however: 1) You end up with duplicate emails in gmail (I just archived all the copies) 2) Nested folders don't seem to come across very well, so I had to recreate the folder structure a bit. Apart from that it seemed to work ok. Ty – mrwooster Jul 31 '11 at 17:45
  • @martineau Yes, I had IMAP on one PC and POP3 on another one, and moved my emails from POP to IMAP. – Nicu Zecheru Aug 1 '11 at 11:13
  • @m4wooster You're welcome. Folders created in your email client are actually Labels on GMail, this is why nested folder's don't come across very well. – Nicu Zecheru Aug 1 '11 at 11:15

You can export your email messages from Thunderbird to an IMAP account preserving the folder structure and avoiding duplicates using MsgExtract.

MsgExtract verifies if the message exist at the target folder prior to uploading it.

You can also suppress the top most folders when replicating the folder structure:


(Disclaimer, I am the author of MsgExtract)

  • And I would have to pay $45 for a licence as the free trial is limited to the extraction of 20 messages per folder. For a one time operation I think that's too high a price. – Sam Hasler Apr 30 '13 at 7:36
  • 2
    We have a 30-days limited license priced at $15 – jponce Apr 30 '13 at 14:58
  • Ah, found them: maildev.com/buy/#itab1-tmplic That's more reasonable. – Sam Hasler Apr 30 '13 at 15:10

This post from Google might answer your question on how the transition will work:

How do actions sync in IMAP?

Here's a guide to how other actions in your IMAP client will appear in the Gmail web interface.

I'm not really sure though how this will help you, it just explains how working with IMAP is translated to Gmail.


First of all, I thought that the question title is somewhat misleading, because there is no folder structure in the Gmail account to keep. For all I'm concerned, it's supposed to be created.

That being said, I believe copying your local folder structure to your Gmail account is probably the most simple approach. To showcase the procedure, I created a fresh Gmail account and set it up in Thunderbird:

Setting up Gmail account

I made sure to leave messages on the server, which is probably how your account was set up as well:

Leave messages on server

Now, the first thing that comes to mind is

Set up filters in Gmail to replicate your folders

If you always sorted your mail in Thunderbird manually, this is probably not going to be your solution. But if you utilized the Message Filters in Thunderbird to sort your mail into folders, it's probably the easiest path to set up filters in Gmail to apply Labels to your mail.

This will sort your current email and also sort future emails into the correct folder. Something that you will probably find very helpful. Let's look at an example:

Message Filters

The "Amazon" filter

So, this is a filter that looks for the word "Amazon" either in the subject or the sender address. Let's set up the same filter in Gmail. However, it should be noted that the folders in Gmail work a bit different from the folders in Thunderbird. A mail simply has a label attached to it. All mails with the same label can then be seen in the folder assigned to that label.

But this doesn't mean the mail disappears from your inbox. So, for proper sorting, you're going to want to make sure to not place the mail in your inbox. We'll take care of that in a second. Let's begin with the first step.

  1. Click the little triangle in the search box.

    enter image description here

  2. In the resulting form, we can define our search, which we will then turn into our filter. Define the search as shown below. And then click Create filter with this search.

    enter image description here

  3. In the next step, you're going to want to check Skip the Inbox (Archive it). This will make sure the mail only appears in the designated folder.

    You'll also want to apply your label here. To do so, check the box Apply the label, then click Choose label... and then New label.... I'm going to name my label Amazon.

    enter image description here

    Last, but certainly not least, you're going to want to check the box Also apply filter to 1234 matching conversations. This will move all your existing messages from the inbox, to which the filter applies, to the new folder.

    enter image description here

  4. If you now force Thunderbird to reload the IMAP folder structure, you'll see your new Amazon folder with all the mail sorted into it.

I sort my mail manually

So you don't use message filters in Thunderbird and you also don't plan to set them up on Gmail. You simply want your existing local folders to appear in Gmail exactly as they currently do locally, while avoiding to create any duplicate mail items.

The solution has already been given by Nicu Zecheru, just copy all the local mail items to the IMAP account.

However, you've noted 2 issues with that procedure.

  1. You end up with duplicate emails in Gmail
  2. Nested folders don't seem to come across very well.

Regarding 1, I would simply clear my All Mail folder before moving the mail over. Then you end up with only your (previously) local mail.

Regarding 2, I was unable to reproduce this issue. I copied my archive of Stack Exchange newsletter to the newly created account. And the nested folder in it appeared just fine in Gmail. Just make sure to copy your folders to the root of your account and not nest them within the Inbox or [Gmail] folders.


enter image description here


enter image description here

  • I hadn't considered deleting everything from gmail before uploading, I guess that would work but I'm not convinced I have everything in gmail downloaded so it would be nice if there was a way to verify that first. – Sam Hasler May 17 '13 at 11:12
  • @SamHasler: You could download all messages first and remove all duplicates locally. In the past, I've used addons.mozilla.org/en-US/thunderbird/addon/… to achieve that. I don't know how practical it would be in your situation. – Der Hochstapler May 17 '13 at 11:17
  • If I understand how that addon works correctly I don't think it will help. If messages aren't in the same folder (which they won't be as pop emails are sorted into folders and gmail emails aren't) then it won't find a duplicate. – Sam Hasler May 20 '13 at 9:16
  • @SamHasler: If that's how far you're willing to go to verify a suggestion, then I don't think I can help you :) – Der Hochstapler May 20 '13 at 11:32

Gmail doesn't really have folders, just labels, although it maps labels to virtual folders for IMAP. So really what you are talking about is labeling the emails you've already uploaded.

I might take this opportunity to organize my emails and folders using filters, but that probably wouldn't work for me because too many of my folders are not based on the kinds of things a Gmail filter can detect.

I had something of a similar issue when I wanted to make my old pre-Gmail emails searchable by Google. It was hard because I had been using Eudora which didn't even run anymore but I was able to import the emails preserving the folder structure into Thunderbird and then upload from Thunderbird. Of course, I didn't have the duplicates problem because these had never been in Gmail.

Probably what I would do in your case is create a 'zzOldGmail' label and label everything in Gmail (all mail in "All Mail") with it and "archive" all of it. Then upload my POP mail via IMAP. This way I can separate the duplicates easily but I don't have to worry that maybe I deleted the only copy of some piece of mail.

  • You're correct, I do want to apply my current folder names as labels. The emails have been manually sorted, so filters aren't an option. I don't see how applying a label to All Mail will help, the emails I upload via IMAP folders (i.e. label) will have labels, whilst the old emails won't, so I can already tell them apart. – Sam Hasler May 20 '13 at 9:12
  • @Sam, lack of label is not a good label. What happens when you label one of those old emails? Now you don't know where it came from and you no longer have a distinctive label to use for future actions. Having the zzOldGmail label will make it much easier to look for duplicates or non-duplicates in the future. – Old Pro May 20 '13 at 17:15
  • Ah, I misunderstood you then. I thought you were proposing a solution that would allow deduplication as a one off event (so label or no label on old gmail would be the same at that point), not an ongoing process. – Sam Hasler May 21 '13 at 7:49
  • @Sam, the thing is, you didn't explain your duplication situation. I'm assuming that all the email are duplicated and that you don't have so much email that Gmail won't store the dups. In that case, you upload all the folders and use them and just keep around the zzOldGmail in case one slipped through. When you're satisfied all is good then you move all the zzOldGmail to the trash and you're done. – Old Pro May 21 '13 at 7:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.