1. Make sure IMAP is enabled in your GMail account settings (on mail.google.com)
  2. File/New/Account/Email_Account and click Nexw
  3. Identity: Enter your firstname and lastname, plus youremail@yourdomain.com and click Next
  4. Server Information:
    • Server type = IMAP
    • Incoming server: imap.gmail.com
    • Outgoing server: smtp.gmail.com
    • ...and click Next
  5. User Names
    • Incoming user name: youremail@gmail.com
    • Outgoing user name: youremail@gmail.com
    • ...and click Next
    • Click Next until the wizard completes
  6. Rename the account to Account Name = gmail.youremail@yourdomain.imap
  7. Take TB offline without downloading email (I'm behind a firewall)
  8. Further TB setup
    1. Tools/Account Settings
    2. Select gmail.youremail@yourdomain.imap
    3. Server Settings:
      1. Port = 993
      2. Use secure connection = SSL
      3. Check for messages at startup = true
      4. Check for new messages every 55 minutes
      5. When I delete a message: Remove it immediately (Paradoxically, this will retain the email in your "All Mail" folder.  The one thing that Google IMAP uses to trigger deleting an email from All Mail is when a message gets moved to Trash.)
    4. Select Outgoing Server (SMTP)
      • Select smtp.gmail.com and click Edit
      • Enter smtp.gmail.com as the Server Name and set the Port to 587
      • Username = youremail@gmail.com
      • Use secure connection = TLS
      • Note: If you just can't get it to connect for SMTP, it may be that your employer has blocked access to port 587 via the corporate edition of McAfee.  Employers used to just block port 587 via their firewalls.  However, when people took their company-owned laptops home, they were then able to connect in GMail.  So some have taken to configuring the corporate edition of McAfee to prevent all processes on your PC from connecting to port 587 on ANY server.
        • To see if this is the case:
          • Set up Portable Thunderbird and get SMTP working from another PC that you know does not block port 587.
          • Copy that Portable Thunderbird to your laptop.
          • See if it now fails.  If it does, you know that your laptop has port 587 blocked.
        • If you need to use SMTP anyhow:
          • Configure Thunderbird to use a proxy: SOCKS, localhost, 8080 (via Tools/Options/Advanced/Network & Disk Space/Connection)
          • Set up an ssh SOCKS proxy on port 8080.
  9. Click Get Mail in TB
    • If it asks to go online, tell it OK.
    • Take it offline afterward. (Click the light-bulb in the status bar.) Tell it do download messages for offline use.
  10. Change the default location for Sent and Drafts to [Gmail]/Sent Mail and [Gmail]/Drafts respectively by doing:
    • Tools/Account Settings/Copies & Folders
      • When sending messages, automatically place a copy in
        • Other
        • gmail.youremail.imap/Gmail/Sent Mail
      • Keep message drafts in: "Drafts" Folder on Local Folders
      • Keep message templates in: "Templates" Folder on Local Folders
  11. More Config
    1. Check (right-click on, select Properties/Offline)  Enable offline access for Inbox, Sent Mail, Trash, All Mail, Spam.
      • I don't enable it for Drafts, because this can lead to a bunch of copies of the message when using Tbird with Google IMAP.
      • I do perform the following Trash folder alignment exercise from Lifehacker.  I like the behavior that deleting a message deletes all copies of it (even those you said to 'copy' to another Tbird folder).  Note that if you really want to keep the other copy, you can move it to your "Local Folders" message store.
        • Tools/Options/Advanced/General
        • Hit the "Config Editor" button next to the "Advanced Configuration" label.
        • Using the filter entry box at the top, type in mail.server.server and you will see a list of keys and values. One of those keys will be mail.server.serverX.name, where X is a number and the value is the name of your Gmail IMAP account. Remember X.
        • Right-click somewhere in the box and select New->String.
        • A dialog box will pop up asking for the name of your new key. Put in mail.server.serverX.trash_folder_name, where X is the number you remember from above. (For example, mine is mail.server.server2.trash_folder_name.)
        • A new box will come up asking for the value of your new key. Put in [Gmail]/Trash
        • Go to Gmail's web interface and delete the label [Imap]/Trash.
        • Restart Thunderbird. 
  12. Open each of your folders in Thunderbird, and let it download all message headers. (Slow.)
  13. Go offline.