Configuring Thunderbird for Gmail IMAP the way it should be done
I recently made a post on how to configure Windows Live Mail Beta (client) for Gmail’s new IMAP offering. I wasn’t very comfortable with the application and wanted to give Thunderbird a try (again). Although Foxmail has been my primary e-mail client, it does not support IMAP.
The first step is to follow the instructions at the Gmail Help Center for setting up Thunderbird as you IMAP client. Once that is done you still have to configure your folders to map accordingly Gmail.
When you follow the steps at the Gmail Help Center, you end up with a folder list like the following:

The [Gmail] folder has sub folders containing the your actual primary set of folders of your Gmail account (Inbox, Starred, Sent Mail, Drafts, All Mail, Spam & Trash). All your labels are shown as folders outside of this. There is an easy method to map your primary folders correctly to Gmail’s, but doing so will deprive you of access to your labels (which show up as folders in Thunderbird).
So the cleanest way to map the folders is to do the following:
1. In Thunderbird select Tools->Account Settings and select the account that you are using for Gmail IMAP.
2. Select Copies & Folders under that.
3. Sent Mail: Choose ‘Other’ for the “When sending messages, automatically: ” and from the drop down select “AccountName”->[Gmail]->Sent Mail
4. Drafts: For drafts as well, choose “Other” and from the drop down select “AccountName”->[Gmail]->Drafts
5. Spam: Select “Junk Settings”, check the “Move junk messages to”, select “Other” and from the drop down select “AccountName”->[Gmail]->Spam

This fixes most of your folders. The only remaining one is “Trash” and fixing this folder is a bit cumbersome, but it is worth it. By default Deleting a message does not send it to your Gmails “Trash” folder, instead it sends it to Thunderbirds Trash folder. The way IMAP is set up is that Thunderbirds Trash folder is mapped to [IMAP]/Trash on Gmail. So here are your options
1. Let it remain as is and you will have an extra label called [IMAP]/Trash in Gmail, under which all your deleted mails will reside.
2. If you want your deleted mails to be removed from your inbox, but still exist (in your ‘All Mails’ section) then map your trash to ‘[Gmail]/All Mails’
3. If you want your deleted mails to be removed from your inbox, and actually be trashed then map your trash to ‘[Gmail]/Trash’
(1) requires no further action on your part, but (2) & (3) are essentially the same thing, only differing in folder names.
So here’s how you go about fixing your trash folder:
1. Close Thunderbird
2. Go to C:\Documents and Settings\<windows_username>\Application Data\Thunderbird\Profiles\<profile_name>, where <windows_username> is your windows logon and <profile_name> is the current Thunderbird profile you are using.
3. Open prefs.js in your favorite text editor and search for a line that says user_pref(”mail.server.server#.directory-rel”, “[ProfD]ImapMail/imap.gmail.com”);
Here server# refers to your server number. Basically we have to find out which server number is being used for our Gmail IMAP
4. Just below that line, add an additional line that says user_pref(”mail.server.server#.trash_folder_name”, “[Gmail]/Trash”);
5. Startup Thunderbird again and your Trash folder below the Inbox should no longer be there. Instead it will use [Gmail]/Trash. If it does show up, then restart Thunderbird a couple of times until the Trash folder below the Inbox goes away. I have no clue why this happens, but this is a quirk I’ve noticed.
Now anything you delete would go to the actual Trash. If you wanted it archived instead of trashing it, specify [Gmail]/All Mail as the trash_folder_name.
Thunderbird should now be configured to properly work with Gmail’s IMAP.
followed this howto, but Thunderbird deletes the whole Gmail-account after restarting…
[...] figuring out on my own what I need to do, I found the steps online written here: The [Gmail] folder has sub folders containing the your actual primary set of folders of your Gmail [...]
@Dieter Kiesel
Deletes the whole Gmail account? I managed to configure 2 Gmail accounts on Thunderbird this way… I did it on Windows, although I’d imagine it wouldn’t be any different on Linux or any other operating system.
Instead of hand editing the prefs.js, an easier method (maybe) is to go to Edit -> Preferences -> Advanced tab -> General tab -> Config editor button. Then basically do what you said to create the new line…
@Brett
Yep, it could be done that way as well. Might be easier
Just curious - how did you get the [Gmail] folder to be listed first in the folder pane? That doesn’t seem to happen for me
If you use the details specified on Google’s help section for configuring Gmail for IMAP, you end up with a default layout that has [Gmail] in it. You need to configure your folders in thunderbird to get rid of it. Unless they’ve changed something
Came across this just today and thought I’d post a possible warning on it.
I haven’t been brave/stupid enough to test this, but what exactly would happen if you mapped your trash folder to ‘[Gmail]/All Mail’ and then told Thunderbird to ‘empty the trash folder’?
I may be wrong, but I would be afraid of it deleting all of my email (forever?). Which would tie in to one of the comments already posted.
@Davo
I haven’t tried this and would rather not (and recommend no one does) :D. If anyone does try this tho’ (Like on a new account or something), do let us know what happened
Just tried this on Mac OS X - Thunderbird. When I restarted my gmail account dissapeared just like Dieter Keisel said. any idea what went wrong? and how I can retrieve it back?
@katyousha
Haven’t tried this in a while (after first configuring my accounts I haven’t had the need to redo it), but gmail now has new features that allow you to specify which labels show up in IMAP. Do any of the folders show up for you? And has your mail been deleted from your online account or is it that they just don’t show up in Thunderbird?
Ramesh - the accounts (all not just gmail) were removed from Thunderbird. The mail is still in Gmail… It’s just a pain having to reset it up again. Yes I noticed that Gmail has now better imap features only release a few days ago. IMAP labs. So will be testing it out. thanks!
Thanks for this blog entry. I couldn’t get the Trash hack to work until I did your trick of restarting Thunderbird multiple times.