简体   繁体   English

如何使用Zend_Mail_Protocol_Imap或Zend_Mail_Storage_Imap批量检索电子邮件

[英]How to do batch retreival of email using Zend_Mail_Protocol_Imap or Zend_Mail_Storage_Imap

I am using Zend_Mail_Storage_Imap to access email but using following code 我使用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";
}

My problem is that it loops and get one email at a time which is slow like getting two emails per second which is very slow . 我的问题是它循环并一次收到一封电子邮件,这很慢,就像每秒收到两封电子邮件一样慢,这很慢。 I am looking for batch retreival method of these mails but could not find any . 我正在寻找这些邮件的批量撤销方法,但找不到任何。 Did anybody do it before 有没有人以前做过

Finally got it. 终于明白了。

Where $imap is an instantiated and connected version of Zend_Mail_Protocol_Imap: 其中$ imap是Zend_Mail_Protocol_Imap的实例化和连接版本:

  1. $imap->select(); // or $imap->select('FOLDER_NAME');

  2. $imap->requestAndResponse('SEARCH UNSEEN', $imap->escapeString('*'))//all unread email ids

  3. $imap->requestAndResponse('SEARCH UNSEEN FROM "someEmail@gmail.com"', $imap->escapeString('*'))//all unread email id's from someEmail@gmail.com

  4. $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

*You must do #1 above first or else you'll get something similar to: "TAG# BAD SEARCH not allowed now." *你必须先做上面的#1,否则你会得到类似的东西:“现在不允许TAG #BAD SEARCH。”

All of the above will return an array similar to the below array: 以上所有都将返回一个类似于下面数组的数组:

//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.

相关问题 尝试使用Zend_Mail_Storage_Imap提取电子邮件时,“检测到无效的标头值” - 'Invalid header value detected' when trying to fetch email with Zend_Mail_Storage_Imap 得到错误消息PHP致命错误:调用未定义的方法Zend_Mail_Storage_Imap :: requestAndResponse() - getting error message PHP Fatal error: Call to undefined method Zend_Mail_Storage_Imap::requestAndResponse() Zend Mail Imap-将电子邮件复制到已发送的文件夹 - Zend Mail Imap - copy email to sent folder 如何验证Zend \\ Mail具有打开的IMAP流? - How do I verify that Zend\Mail has an open IMAP Stream? 如何从zend mail imap中提取内容? - How do I extract the content from zend mail imap? Zend \\ Mail \\ Storage \\ Imap.php是否挂断了我的服务器? - Is Zend\Mail\Storage\Imap.php hanging up my server? php imap_mail不提供电子邮件 - php imap_mail do not develiver email zend framework:将imap邮件设置为阅读或将其移动到文件夹 - zend framework : set imap mail to read, or move it to a folder Zend_Mail - 从GMAIL获取IMAP附件 - Zend_Mail - Fetch IMAP Attachements from GMAIL 无法在 Zend 中使用 gmail SMTP 发送电子邮件。 出现致命错误:未捕获的异常“Zend_Mail_Protocol_Exception”。 如何解决这个问题? - Unable to send email in Zend using gmail SMTP. Getting Fatal error: Uncaught exception 'Zend_Mail_Protocol_Exception'. How to fix this?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM