我正在使用以下代码来获取 Gmail 中的未读电子邮件计数。但是,它返回错误:
can't connect: Too many login failures
我在这里有什么遗漏吗?
(我正在测试的 Gmail 帐户中启用了 IMAP 和 POP。)
注意:看起来它正在工作(至少对于大多数请求)。但是,它需要的时间太长了——可能需要 2 到 3 分钟才能得到一个数字。有没有办法加快速度?
谢谢!
<?php
$mbox = imap_open ("{imap.gmail.com:993/imap/ssl/novalidate-cert/norsh}Inbox",
"username", "password", OP_READONLY)
or die("can't connect: " . imap_last_error());
$check = imap_mailboxmsginfo($mbox);
if ($check) {
print $check->Unread; //. "/" . $check->Nmsgs;
} else {
print "Failed";
}
?>