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

9

173

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.

Calfee answered 2/12, 2013 at 20:18 Comment(3)
I know this is old, but, the other way to get this working is to copy the text from the gmail server (that has been edited out from the OP) and modify it so you have a nice long URL string with lots of characters. Then, enter that URL in to your browser and it should work.Christcross
in my case i tried to use Vercel serverless functions and turned out it was issue on their end because they don't support smtp stuff. So if case you get here and you use vercel serverless functions, you should use some other provider, not gmail. more details here vercel.com/docs/solutions/emailBattalion
Latest solution using Google app passwords posted https://mcmap.net/q/144647/-heroku-smtplib-need-to-log-into-browser/64896891#64896891Tempi
P
331

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.
Paddy answered 11/8, 2014 at 8:9 Comment(15)
Recently, I was working on PHPmailer. I was trying to send emails from my local server (WAMP). But, I was not able to send emails because of this error. After spent 2 hrs I found your answer 'Correct' to fix my error. Thank you so much.Sharlenesharline
Thank you so much, this is the missing step i am looking for. thanksCollation
Note to all: You have to do this if you are going to access your account via Outlook as wellPipit
I can confirm it works!Maricela
Spent hours wondering why PHPmailer wasn't working - this was it, thanks!Planography
Bloody hell... as usual.. this doesn't work for meAirlie
it's no longer working. I turn on Access for less secure apps and I still get the same message as google prevent the login. I have just tried it in AWS EC2 using nodemailerChaves
@MarkThien I just tried from my local machine using nodemailer and it worked fine.Paddy
What the heck...I had to do this to add another Gmail account as a send-as address in Gmail itself! "All Google products use the latest security technologies" my butt.Diluent
Note that I had to actually TURN ON 2-Step Verification, but once I had this worked. (For some reason beforehand it'd work from one computer but not another.)Mercurialism
I had very tired because search some answers about this problem. Now i found it really I'm very happy!!! Thanks so much Duncan!!!Bile
Thank you, thank you, THANK YOU! Google ended up blocking access from my device because it was "new". I added it to the list of accepted devices, but still had to complete the "DisplayUnlockCaptcha" part before it would work.Telescopium
@MarkThien did you solve your problem. I'm using AWS EC2 too and I have the exact same problem: https://mcmap.net/q/144648/-smtp-error-failed-to-connect-to-server-0/1817673Spectrohelioscope
it worked locally, but when I deployed to my server it gives me Please log in via your web browser and then try again. Gmail is a waste of time, I wish people stop using it in packagesBalmung
WARNING FOR OTHERS: In my case, setting the Gmail server as shown above worked, but not instantly. They took effect after some minutes (10 maybe?).Dampier
B
151

I did this every time the problem happens:

https://accounts.google.com/DisplayUnlockCaptcha

  • problem sorted in my case!
Bennington answered 29/4, 2014 at 6:31 Comment(5)
This, I don't obviously understand why, works for me (after doing 'less secure' way above)Rackrent
I completely agree with @Abdillah. In fact, after this worked for me, Google then sent me an SMS on my cell phone about a suspicious activity and asking to visit google.com/blocked !!Rakia
This worked for me, too. Nothing else worked. Weird, going to the link they provided did not work. Thank you so much for this answer. It's really odd that this doesn't seem to be documented.Mooned
In our case we are using javaxmail with IMAP settings, we sorted out already for other account by turning ON less secure apps; but for a second app we forgot that and the application tried too many times in the server, so our guess is that said device/location got completely blocked for login even after we turned ON less secure apps; anyhow using the provided link above accounts.google.com/DisplayUnlockCaptcha we got a message saying "Account access enabled: Please try signing in to your Google account again from your new device or application." which we did and it started working.Birddog
I did this and it works great but after some time its giving errors and I need to do this againReorder
S
39

I recently got this message, too, after I switched the data center location of a web application sending through Google SMTP.

The URL that apparently Google means is: https://support.google.com/mail/answer/78754. At that link, one of the steps is to reset your password. Not coincidentally, I also received an email from google with a subject of "Suspicious sign in prevented" that instructed me to change my password.

After resetting my password, I was back to using Google SMTP as usual.

Sension answered 17/12, 2013 at 22:9 Comment(3)
Thanks! This is the correct answer. I logged in, I changed my password, and everything worked after that.Amendatory
in my case, i hade todo both: change the password and after that enable unsecure access, because even after enabling unsecure access, it was reset to disable, without doing anything from my side, very strange.Drennen
Also, you need to check the suspicious access allowed with the account you want to use. In that way you can grant access from the instance | server that use your gmail account. After that I update my password and I am ready to go!Impair
B
25

I know this question is already been answered but for new comers those two solutions may help:

  1. Make sure your gmail is allowing low secure apps to sign in, you can turn it on here: https://www.google.com/settings/security/lesssecureapps.
  2. Change your password.
Beitch answered 9/9, 2015 at 0:55 Comment(5)
This answer is tested today 22 Aug 2016 and works great!!Powered
I followed everything above, nothing helped until I changed by password. Thanks a lot mate! (18 Jan 2017 tested and works)Priggery
@Priggery Glad to hear it helped you.Keats
Using "Less Secure Apps" method tested and works as of today August 19 2017 :)Doura
After enabling "less secure app" you need to change password then it worksPrejudicial
C
15

There are two ways to resolve this, and only one may work, depending on how you're accessing Google.

The first method is to authorize access for your IP or client machine using the https://accounts.google.com/DisplayUnlockCaptcha link. That can resolve authentication issues on client devices, like mobile or desktop apps. I would test this first, because it results in a lower overall decrease in account security.

If the above link doesn't work, it's because the session is being initiated by an app or device that is not associated with your particular location. Examples include:

  • An app that uses a remote server to retrieve data, like a web site or, in my case, other Google servers
  • A company mail server fetching mail on your behalf

In all such cases you have to use the https://www.google.com/settings/security/lesssecureapps link referenced above.

TLDR; check the captcha link first, and if it doesn't work, try the other one and enable less secure apps.

Cravens answered 23/10, 2015 at 21:12 Comment(3)
it was useful for me, thank youAcademia
This fixed my issue, thanksSulfonmethane
Thank you. Fixed the issue!Castera
J
10

To send mail using Gmail SMTP, need to change your account setting. Login into your gmail accout then follow the link below to change your gmail account setting to send mail using your apps and program. https://www.google.com/settings/security/lesssecureapps

Note: This setting is not available for accounts with 2-Step Verification enabled. Such accounts require an application-specific password for less secure apps access.

Joellajoelle answered 20/11, 2014 at 10:29 Comment(2)
It worked for me also.I was using hMail serverHoopen
@Muk Glad, it worked for you.Joellajoelle
U
2

I also came across this problem. Google detected my Mac as a new device and blocked it. To unblock, in a web browser log in to your Google account and go to "Account Settings".

Scroll down and you'll find "Recent activities". Click just below that on "Devices".

Your device will be listed. Okay your device. SMTP started working for me after I did this and lowered the protection as mentioned above.

Unburden answered 6/4, 2015 at 6:37 Comment(0)
M
0

There are at least these two issues I have observed for this problem: 1) It could be either because your sender username or password might not be correct 2) Or it could be as answered by Avinash above, the security condition on the account. Once you try SendMail using SMTP, you normally get a notification in to your account that it may be an unauthorized attempt to access your account, if not user can follow the link to turn the settings to lessSecureApp. Once this is done and smtp SendMail is tried again, it works.

Misconception answered 19/5, 2015 at 13:5 Comment(0)
N
0

Some apps are marked as less secure by google, so you just need to give access for those app so google will allow you to access its services to you.

follow this http://www.codematrics.com/your-imap-server-wants-to-alert-you-to-the-following-please-login-via-your-web-browser-gmail/

Nakia answered 16/9, 2015 at 17:30 Comment(1)
Link in answer seems dead.Arleen

© 2022 - 2024 — McMap. All rights reserved.