Connection error: Can not authenticate to IMAP server: [ALERT] Please log in via your web browser
Asked Answered
C

5

5

I am using a php script to connect imap.gmail.com, I have a paid google app account. It was working but after some time I am getting following error

  1. it says I have to login from browser but my CentsOS vps server does not have a browser its command prompt only

I am using mydomain.com

Fatal error: Uncaught exception 'ImapMailboxException' with message 'Connection error: Can not authenticate to IMAP server: [ALERT] Please log in via your web browser: https://support.google.com/mail/acco' in /xxxxxx/classes/ImapMailbox.php:51 Stack trace: #0 /home/theluxla/public_html/_backoffice/mailpilot/classes/ImapMailbox.php(42): ImapMailbox->initImapStream() #1 /xxxxxx/classes/ImapMailbox.php(114): ImapMailbox->getImapStream() #2 /xxxxxx/mail.v3.php(28): ImapMailbox->searchMailbox('ALL') #3 {main} thrown in/xxxxx/classes/ImapMailbox.php on line 51

Capitally answered 27/6, 2016 at 6:55 Comment(3)
Have you tried searching for the error message? A quick search led me to this answer - have you tried any of those suggestions?Iodate
It's a security flag. The only real way to get rid of this issue is to use OAuth. But you can try logging in from YOUR browser, and seeing if it asks you to approve the login.Cockburn
Still my problem is not solved, I was asking about my problem but always somebody will redirect to a different thingCapitally
C
8

Google replied to me:

Thank you for your message. I understand you're having issues connecting your application with our IMAP server, I'll be happy to help. I didn't want to bother with a call this early, reason why, I'm sending this email instead In this case, it seems this error is related to the access to "Less secure apps" disabled for the user you're trying to connect via IMAP. Please follow these steps to solve this issue:

  1. In your Admin Console, follow the steps available at this support article https://support.google.com/a/answer/6260879?hl=en under the section "Enabling less secure apps to access accounts".

  2. Log in as the affected user and follow the steps to "Allow less secure apps to access your account" as described at this support article https://support.google.com/accounts/answer/6010255. I hope this information is helpful. Your case will remain open for three business days and it will auto close if no reply is received. Feel free to reply to this message if you need more help, I'll be happy to continue assisting you.

Sincerely,

David

Capitally answered 2/7, 2016 at 7:43 Comment(1)
This was really helpful, since I am working on some old library for IMAP which is just giving unable to logingBillboard
A
7

In may case, Gmail block my server IP

So do the below step to solve this thing.

You need to first Sign in - Google Accounts https://accounts.google.com

You probably need to go here and follow the instructions: https://accounts.google.com/b/0/DisplayUnlockCaptcha

Ariana answered 26/2, 2020 at 7:48 Comment(3)
This was a real hack actually :)Tenure
After several hours of banging my head against the wall, disabling and re-enabling IMAP and less secure app access, thank you sooooo much.Dissuade
For me this worked only from within a new (private) Chrome session.Urumchi
D
4

Change Gmail accounting setting:-

Enable IMAP.

Status: IMAP is enabledenter image description here

Dimitri answered 3/1, 2018 at 13:10 Comment(0)
L
0

https://myaccount.google.com/u/2/security-checkup?utm_source=google-account&utm_medium=web&continue=https%3A%2F%2Fmyaccount.google.com%2Fu%2F2%2Fsecurity

In the “Third-party access” tab turn ON less secure app access

Try to access, you will still be denied

https://myaccount.google.com/u/2/security-checkup?utm_source=google-account&utm_medium=web&continue=https%3A%2F%2Fmyaccount.google.com%2Fu%2F2%2Fsecurity

in the “Recent security events” tab you will find a note about your last access, tell that it was you and you will be able to access

Lotetgaronne answered 4/2, 2019 at 8:48 Comment(0)
H
0

In my case none of the proposed answers helped. All options were checked: IMAP -enabled, Less secure apps - enabled, this instruction: https://accounts.google.com/b/0/DisplayUnlockCaptcha also didn't work.

POSSIBLE PROBLEM: use of multiple Gmail accounts (when you connected to many Gmail account and can switch connections). Also if you use the browser like Chrome with profile signed to one of the Google Accounts. In my situation the instruction: https://accounts.google.com/b/0/DisplayUnlockCaptcha didn't work, because I was primarily using browser Chrome profile of my personal Google account, but was working on connection 3rd party app that was using another Google account.

MY SOLUTION. I've added another Chrome profile (corresponding to 3rd Party Gmail Account), switched from my personal profile to working one. And only after that the instruction of https://accounts.google.com/b/0/DisplayUnlockCaptcha gave the positive result. Hope it will save few hours for you.

Hebraic answered 6/12, 2021 at 13:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.