php – imap_num_msg返回的计数少于pop协议收件箱中的实际电子邮件数

开发技术 作者: 2024-07-02 21:05:01
我正在尝试使用gmail的电子邮件作为退回地址处理phplist中的退回电子邮件.当我试图处理弹跳时,我陷入了 Post – There are 250 bounces to process中提到的类似场景中. Phplist只能从我的Gmail帐户中获取250封电子邮件.在进一步调查phplists的代码时,我遇到了这行似乎是罪魁祸首的代码. $num = imap_num_msg($link)
我正在尝试使用gmail的电子邮件作为退回地址处理PHPlist中的退回电子邮件.当我试图处理弹跳时,我陷入了 Post – There are 250 bounces to process中提到的类似场景中.

PHPlist只能从我的Gmail帐户中获取250封电子邮件.在进一步调查PHPlists的代码时,我遇到了这行似乎是罪魁祸首的代码.

$num = imap_num_msg($link); //只计算250

跳过更多细节.我写了几行代码来使用imap和pop来获取邮件数量. pop版本返回错误的计数,而imap版本返回的是正确的

$username = 'bounceemail@mydomain.com';
$password = 'password';

$hostname = '{imap.gmail.com:993/imap/ssl}INBox';
$inBox = imap_open($hostname,$username,$password);
$num = imap_num_msg($inBox);
echo $num; // prints 65,051 ( correct one)

$hostname = '{pop.gmail.com:995/pop3/ssl}INBox';
$inBox = imap_open($hostname,$password);
$num = imap_num_msg($inBox);
echo $num; // prints 250 as count ( wrong one)

我实际上需要知道为什么不同协议的同一电子邮件的计数不同.此外,我在互联网上发现的所有帮助与PHPlist弹跳处理明确要求使用{pop.gmail.com:995/pop3/ssl}INBox版本.所以我不能冒险使用其他版本来处理退回.

解决方法

Gmail具有非标准POP实施,一次只能展示250-300封邮件,直到您下载并删除它们为止.或者,如果您使用recent:username作为用户名,则会显示过去30天.

无论哪种方式,如果您想要完全访问您的Gmail帐户,您需要使用IMAP.

原创声明
本站部分文章基于互联网的整理,我们会把真正“有用/优质”的文章整理提供给各位开发者。本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
本文链接:http://www.jiecseo.com/news/show_37494.html

猜你喜欢