我使用PHP IMAP庫從Barbushin包裹在方便的小類:https://github.com/barbushin/php-imap使用PHP IMAP連接到交換服務器,交換服務器使用什麼標誌用於UNSEEN電子郵件?
,我開始對我的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');
這將檢索所有emai在交換機上的收件箱裏(根據我的連接),我很好。
UNSEEN
(如文檔所述)在Google Mail上按預期工作,但未在Exchange 2010上正常工作。ALL
按預期在兩者上均可正常工作。我想知道Exchange 2010是否使用了不同的標誌? NEW
和UNREAD
也不起作用。而且,我可以從這些郵件ID中獲得的返回細節不包含要從其進行反向工程的數組。
任何幫助,將不勝感激:)
正是我所想的。這不是微軟第一次完全忽視標準化的想法。謝謝! –