Question

GMail can used as a SMTP server. I've written the code that does it. But as we all know GMail may occasionally authenticate using captcha (image verification as they call it). The same thing may be the cause to reject SMTP authentication.

As I've seen google shows image verification when you try to log-in for the first time from some machine. All consecutive log-ins from the same machine (to the same account) use regular login. I'm a bit afraid this captcha may also come up again for some other reasons that I can't control.

So. Is it possible to still authenticate when special measures are needed? And how?

I should also mention that logging in from the machine via web browser also enables programmatic SMTP authentication.

Was it helpful?

Solution

Google doesn't seem to be particularly clear about what prompts them to block a user's account until he has successfully entered a captcha phrase. However, it's likely that this is a mechanism which is triggered when Google sees what it considers to be unusual or suspicious activity associated with your account. As a result, I would expect it to be unlikely that they will supply an option to opt out of a mechanism which is protecting both them and you, although others are welcome to find evidence to the contrary.

Various discussions of when and how this happens throw up some suggestions which you might like to try to see if they help, such as choosing a stronger password or simply changing your password. Good luck!

OTHER TIPS

Try:

http://www.google.com/accounts/DisplayUnlockCaptcha

Or for Google Apps for your domain:

https://www.google.com/a/yourdomain.com/UnlockCaptcha

I can bet it's an IP based solution, so if your app if deployed somewhere else, It doesn't help.

IMHO The right way to do this, without implementing the user consent workflow or "hacking your account's security settings", is obtaining a refresh token with the Google OAuth2.0 Playground for Offline Access. After that, you can authenticate using the OAuth 2.0 API.

I got it working after reading Nodemailer/Gmail - What exactly is a refresh token and how do I get one?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top