1

我正在尝试从托管在共享托管服务器上的脚本连接到 Gmail。

这是我使用的代码:

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

运行 imap_errors 时,我得到以下信息:

"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"

同时,我在尝试访问的邮箱上收到一封电子邮件,说连接尝试已被阻止,因为用于连接的应用程序(即我的脚本)未遵循最新的安全规范。

他们告诉它可以通过允许“不太安全”的应用程序访问 gmail 设置中的帐户来解决。但这会导致邮箱更易受攻击,这是我不想要的。

我应该使用更新的 php 库来以这种方式登录 gmail 吗?

4

0 回答 0