If you access your gmail through imap and try to setup a mobile phone (such as the iPhone) you may get the error:
“Your IMAP server wishes to alert you to the following: Invalid credentials (Failure)”
To fix this you need to bypass the Google CAPTCHA using the following address
Once you have logged in here your imap connection should work.
Note: For Google Apps users visit https://www.google.com/a/yourdomain.com/UnlockCaptcha instead (with yourdomain.com being your Google Apps domain.)
Remember to use imap with Google mail you need to use SSL with port 993