首页 > 解决方案 > imap gmail中的DDeboer连接失败

问题描述

我需要一些有关 lib DDeboer-Imap 的帮助。我无法连接到 Gmail 帐户,我已经完成了我在互联网上找到的所有可能设置,包括在帐户上启用 imap、启用不太安全的应用程序、禁用任何不正常的活动,但这些都不起作用,我有同样的反馈:

错误响应:

 [ERROR] Error: [E_WARNING] Authentication failed for user "xxxxxxx@gmail.com":
         imap_open(): Couldn't open stream
         {imap.gmail.com:993/imap/ssl/validate-cert}
         imap_alerts (0):
         imap_errors (1):
         - Can not authenticate to IMAP server: [ALERT] Please log in via your
         web browser: https://support.google.com/mail/acco

php 版本是 7.2,所有库都处于活动状态,imap、openssl 和我验证过的其他库都是必需的,正如所说,没有任何东西可以连接帐户。

我也尝试过更改为不使用 SSL 进行连接,但没有成功。

以下是我的代码的摘录。

try {
            foreach ($mailboxes as $key => $mailbox) {
                $hostname = 'custom' == $mailbox['server'] ? $mailbox['imap'] : $mailbox['server'];
                $cert = 143 == $mailbox['port'] ? '/imap/novalidate-cert' : '/imap/ssl/validate-cert';

                $server = new Server($hostname, $mailbox['port'], $cert);
                $connection = $server->authenticate($mailbox['email'], $mailbox['password']);

                $this->readMailboxes($connection, $mailbox);
            }
        } catch (Exception $e) {
            throw new Exception($e->getMessage(), 1);
        }

谢谢!!!!

标签: phpgmailimap

解决方案


推荐阅读