I had been using gmail to send emails from my website for 2 years when all of a sudden my email functionality stopped working. When debugging the issue I found I was getting this error:
“The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required”
So I did some research… most sites had code to fix this however none of it worked form me, like enableSsl = true.
Then I accessed my email and at the top of the page of my gmail account I had a red suspicious login warning bar.
Now this is how I solved my issue:
Login to your gmail account
Click “Was it you?” in the red top bar as in the image above.
They will show you the suspicious login details such as date, IP, etc.
Click Recognize and Allow Access from this machine.
Google will display the steps required as indicated below:
In the case your are accessing gmail from a website, go to the website and fill the contact form or whatever sends the email.
And just like magic, it should work and access will always be granted after that.