PHP imap_search不检测Gmail收件箱中的所有邮件 [英] PHP imap_search not detecting all messages in gmail inbox

查看:671
本文介绍了PHP imap_search不检测Gmail收件箱中的所有邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在我的Gmail收件箱中运行一个非常简单的 imap_search 时,搜索返回的消息比它应该少。



以下是任何拥有GMail帐户的人都可以运行的脚本。

  $ host ='{imap.gmail.com:993/imap/ssl}'; 
$ user ='foo';
$ pass ='bar';

$ imapStream = imap_open($ host,$ user,$ pass)或die(imap_last_error());

$ messages = imap_search($ imapStream,ALL);

echo count($ messages);

imap_close($ imapStream);

这将返回39条消息。但是,我的收件箱中收到了100封邮件,其中一些邮件捆绑在对话中,一些邮件从另一个帐户(SquirrelMail)转发。



任何人都可以复制这些结果,并且/或者告诉我发生了什么?




我试过的其他服务器字符串,都返回相同的结果:

  {imap.gmail.com :993 / imap / ssl / novalidate-cert} 
{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX
{imap.gmail.com:993/imap/ssl} INBOX

GMail的IMAP功能支持: http://mail.google.com/support/bin/answer.py?hl=zh_CN&answer=78761 这是一个令人误解的用户界面。



默认情况下,GMail将用户的消息分组为对话。这些对话可以包括存档消息。因此,例如,Bob的收件箱看起来像是,有4条25条消息的对话,显然应该返回100条收件箱消息。实际上,有60条消息存在档案中(而不是收件箱),所以 imap_search()返回 40 。这些消息魔术般地从存档中取出并放入收件箱对话中。
$ b Settings-> General 菜单中,可以切换对话视图,这将把所有这些顽皮的归档消息放回他们所属的地方,并显示您真正的收件箱视图。


When I run a very simple imap_search on my GMail inbox, the search returns less messages than it should.

Here is the script that anyone with a GMail account can run.

$host = '{imap.gmail.com:993/imap/ssl}';
$user = 'foo';
$pass = 'bar';

$imapStream = imap_open($host,$user,$pass) or die(imap_last_error());

$messages = imap_search($imapStream,"ALL");

echo count($messages);

imap_close($imapStream);

This returns 39 messages. But, I've got 100 messages in my inbox, some bundled in conversations, some forwarded from another account (SquirrelMail).

Can anyone duplicate these results, and/or tell me what's going on?


Other server strings I've tried, all returning the same results:

{imap.gmail.com:993/imap/ssl/novalidate-cert}
{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX
{imap.gmail.com:993/imap/ssl}INBOX

GMail's IMAP feature support: http://mail.google.com/support/bin/answer.py?hl=en&answer=78761

解决方案

After significant hair loss, I've found the answer. It was a misleading UI.

GMail groups one's messages into "Conversations" by default. These conversations can include archived messages.

So, for example, Bob's inbox looks like there's 4 conversations of 25 messages, which should apparently return 100 inbox messages. In reality, 60 of the messages are in the archive (not the inbox), so the imap_search() returns 40. These messages are magically pulled out of the archive and placed into inbox conversations.

In the Settings->General menu, you can toggle conversation view, which will put all of those naughty archived messages back where they belong, and show your true inbox view.

这篇关于PHP imap_search不检测Gmail收件箱中的所有邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆