我正在使用来自 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 成功连接到我的交换服务器,我现在可以执行以下操作:
$imap = new IMAP();
$unseen = $imap->searchMailbox('ALL');
这将在 Exchange 的收件箱中正常检索所有电子邮件(根据我的连接)。
UNSEEN
(如文档所述)在 Google Mail 上按预期工作,但在 Exchange 2010 上没有。ALL
两者都按预期工作。我想知道 Exchange 2010 是否使用了不同的标志?NEW
而且UNREAD
也不行。并且我可以从这些 mailID 中获得的返回详细信息不包含要从中进行逆向工程的标志数组。
任何帮助将不胜感激 :)