Getting error while sending email through Gmail SMTP - "Please log in via your web browser and then try again. 534-5.7.14"

ppalmeida picture ppalmeida · Dec 2, 2013 · Viewed 187.7k times · Source

I'm having problems with gmail smtp server. I already read many posts here in StackOverflow about that subject.

The best post I found about test the connection is this one.

Although it is very well explained the error I'm getting I couldn't find a answer: Google SMTP just says "Please log in via your web browser and then try again". I'm completely sure that the password and the email (both in base64) are well encoded.

As you can see here, in this image:

this image,

there is just one difference I can notice: the [email protected] and password is sent in two steps. In the link above the guy sends both at the same time. Google didn't accepted that. But the fact is, I write auth login Y29udGF0... (user in base64, googles responds: ) 334 UGFzc3dvcmQ6 (wich means "Password: ") YzQ2MjJmNWVi.... (paste my password in base64 and hit "enter")

Then Goggle says: Please log in via your web browser and then try again. 534-5.7.14 Learn more at https://support.google.com/mail/answer/7126229

And I'm going through all this problem because @MediaTemple and @DreamHost are not working with PHPMailer. I already use PHPMailer for a long time ago, in so many different hosts, using SMTP but failed with (mt) and Dreamhost. Now I'm in middle of a project that it >must< work on these two hosts.

Answer

Duncan Hoggan picture Duncan Hoggan · Aug 11, 2014

I know this is an older issue, but I recently had the same problem and was having issues resolving it, despite attempting the DisplayUnlockCaptcha fix. This is how I got it alive.

Head over to Account Security Settings (https://www.google.com/settings/security/lesssecureapps) and enable "Access for less secure apps", this allows you to use the google smtp for clients other than the official ones.

Update

Google has been so kind as to list all the potential problems and fixes for us. Although I recommend trying the less secure apps setting. Be sure you are applying these to the correct account.

  • If you've turned on 2-Step Verification for your account, you might need to enter an App password instead of your regular password.
  • Sign in to your account from the web version of Gmail at https://mail.google.com. Once you’re signed in, try signing in
    to the mail app again.
  • Visit http://www.google.com/accounts/DisplayUnlockCaptcha and sign in with your Gmail username and password. If asked, enter the
    letters in the distorted picture.
  • Your app might not support the latest security standards. Try changing a few settings to allow less secure apps access to your account.
  • Make sure your mail app isn't set to check for new email too often. If your mail app checks for new messages more than once every 10
    minutes, the app’s access to your account could be blocked.