imap_open not working on gmail

时间:2016-04-04 17:00:09

标签: php gmail imap imap-open

I'm trying to connect to Gmail from a script hosted on a shared hosting server.

Here is the code I use :

$mail = imap_open('{'imap.gmail.com:993/imap/ssl}INBOX', $username, $password);

When running imap_errors I get the following:

"Retrying PLAIN authentication after [ALERT] Please…web browser: https://support.google.com/mail/acco", "Retrying PLAIN authentication after [ALERT] Please…web browser: https://support.google.com/mail/acco", "Can not authenticate to IMAP server: [ALERT] Pleas…web browser: https://support.google.com/mail/acco"]
0
:
"Retrying PLAIN authentication after [ALERT] Please log in via your web browser: https://support.google.com/mail/acco"
1
:
"Retrying PLAIN authentication after [ALERT] Please log in via your web browser: https://support.google.com/mail/acco"
2
:
"Can not authenticate to IMAP server: [ALERT] Please log in via your web browser: https://support.google.com/mail/acco"

At the same time I received an email on the mailbox I was trying to access saying that the connection attempt has been block because the application used to connect (ie my script) was not following the most recent security norms.

They told it can be fixed by allowing "less secured" applications to access the account in the gmail settings. But this leads to a more vulnerable mailbox, which I don't want.

Is there a more recent php library that I should use in order to login to gmail this way?

0 个答案:

没有答案