使用PHP IMAP连接到Exchange服务器,交换服务器用于UNSEEN电子邮件的标志是什么?

时间:2013-05-15 09:33:27

标签: php imap exchange-server exchange-server-2010

我正在使用包含在Barbushin的方便小班中的PHP IMAP库:https://github.com/barbushin/php-imap

我开始针对我的Gmail帐户进行测试,该帐户会使用以下内容获取未读的电子邮件。

$imap = new IMAP();
$unseen = $imap->searchMailbox('UNSEEN');

该类中的函数执行以下操作:

/*
 *      ALL - return all mails matching the rest of the criteria
 *      ANSWERED - match mails with the \\ANSWERED flag set
 *      BCC "string" - match mails with "string" in the Bcc: field
 *      BEFORE "date" - match mails with Date: before "date"
 *      BODY "string" - match mails with "string" in the body of the mail
 *      CC "string" - match mails with "string" in the Cc: field
 *      DELETED - match deleted mails
 *      FLAGGED - match mails with the \\FLAGGED (sometimes referred to as Important or Urgent) flag set
 *      FROM "string" - match mails with "string" in the From: field
 *      KEYWORD "string" - match mails with "string" as a keyword
 *      NEW - match new mails
 *      OLD - match old mails
 *      ON "date" - match mails with Date: matching "date"
 *      RECENT - match mails with the \\RECENT flag set
 *      SEEN - match mails that have been read (the \\SEEN flag is set)
 *      SINCE "date" - match mails with Date: after "date"
 *      SUBJECT "string" - match mails with "string" in the Subject:
 *      TEXT "string" - match mails with text "string"
 *      TO "string" - match mails with "string" in the To:
 *      UNANSWERED - match mails that have not been answered
 *      UNDELETED - match mails that are not deleted
 *      UNFLAGGED - match mails that are not flagged
 *      UNKEYWORD "string" - match mails that do not have the keyword "string"
 *      UNSEEN - match mails which have not been read yet
 *
 * @return array Mails ids
 */
public function searchMailbox($criteria = 'ALL') {
    $mailsIds = imap_search($this->imapStream, $criteria, SE_UID, $this->serverEncoding);
    return $mailsIds ? $mailsIds : array();
}

只是imap_search(); http://php.net/manual/en/function.imap-search.php

的便捷包装

通过IMAP成功连接到我的Exchange服务器,我现在可以执行以下操作:

$imap = new IMAP();
$unseen = $imap->searchMailbox('ALL');

这将在Exchange的收件箱中检索所有电子邮件(根据我的连接)。

UNSEEN(已记录)在Google Mail上按预期工作,但不是Exchange 2010. ALL按预期工作。我想知道Exchange 2010是否使用了不同的标志? NEWUNREAD也不起作用。我可以从这些mailID获得的返回详细信息中不包含一组反向工程的标记。

任何帮助将不胜感激:)

1 个答案:

答案 0 :(得分:1)

如果它不起作用,那就是Exchange中的一个错误。 UNSEEN搜索字词对应于缺少\Seen关键字(邮件标记),请参阅RFC 3501, p. 52