Recently I got a strange issue using Thunderbird and a gmail IMAP mail account.
It kept telling me I had an invalid password. I tried everything, and checked by logging in to gmail via a browsers and it all worked fine via browser.
Was this a gmail server issue? I don’t think so. So I did some research and found that devices can get locked out of gmail.
I was on a laptop, but I found articles about iPhone’s being locked out (see: http://www.iphonefaq.org/archives/971486 ) so I thought that perhaps that as part of gmail security other devices can get locked out from imap.
By opening gmail in a browser I went to the url suggested http://www.google.com/accounts/DisplayUnlockCaptcha and the app ran (without asking for a code, and like magic Thunderbird was working with gmail imap again.
Now I can’t be 100% certain that this was not a coincidence, so if this works for you please do leave me a comment.