![](/img/trans.png)
[英]'Invalid header value detected' when trying to fetch email with Zend_Mail_Storage_Imap
[英]How to do batch retreival of email using Zend_Mail_Protocol_Imap or Zend_Mail_Storage_Imap
我使用Zend_Mail_Storage_Imap來訪問電子郵件,但使用以下代碼
$storage = new Zend_Mail_Storage_Imap($imap);
$allIds = $storage->getUniqueId(); // i get all key value pair of meesageid and uniqueid
foreach ($allIds as $k => $v)
{
echo '<li>' . htmlentities($storage->getMessage($v)->subject) . "</li>\n";
}
我的問題是它循環並一次收到一封電子郵件,這很慢,就像每秒收到兩封電子郵件一樣慢,這很慢。 我正在尋找這些郵件的批量撤銷方法,但找不到任何。 有沒有人以前做過
終於明白了。
其中$ imap是Zend_Mail_Protocol_Imap的實例化和連接版本:
$imap->select(); // or $imap->select('FOLDER_NAME');
$imap->requestAndResponse('SEARCH UNSEEN', $imap->escapeString('*'))//all unread email ids
$imap->requestAndResponse('SEARCH UNSEEN FROM "someEmail@gmail.com"', $imap->escapeString('*'))//all unread email id's from someEmail@gmail.com
$imap->requestAndResponse('SEARCH UNSEEN SUBJECT "test" FROM "someEmail@gmail.com"', $imap->escapeString('*'))//all unread email id's from someEmail@gmail.com with the subject of test
*你必須先做上面的#1,否則你會得到類似的東西:“現在不允許TAG #BAD SEARCH。”
以上所有都將返回一個類似於下面數組的數組:
//C: TAG3 SEARCH UNSEEN
//S: * SEARCH 321 323 362 371 377 384 386 387 388 389 416 417 418
//S: TAG3 OK SEARCH completed (Success)
//The above lines are in the format of RFC 1730 to show what was actually sent/received.
array (size=1)
0 =>
array (size=14)
0 => string 'SEARCH' (length=6)
1 => string '321' (length=3)
2 => string '323' (length=3)
3 => string '362' (length=3)
4 => string '371' (length=3)
5 => string '377' (length=3)
6 => string '384' (length=3)
7 => string '386' (length=3)
8 => string '387' (length=3)
9 => string '388' (length=3)
10 => string '389' (length=3)
11 => string '416' (length=3)
12 => string '417' (length=3)
13 => string '418' (length=3)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.