如何使用 zend mail 搜索收件箱
以下是 zend_mail_protocol_imap 中的函数。我读到它是为了搜索电子邮件,我想使用 zend_mail_storage_imap 覆盖它(这就是我现在用来从 gmail 获取电子邮件的方法)。我将以下函数复制并粘贴到 zend_mail_storage_imap 中,但我遇到了参数问题。我找不到有关数组 $params 的使用内容的文档。在更彻底地阅读之前,我最初以为这是搜索词。我没主意了。这是函数...
/**
* do a search request
*
* This method is currently marked as internal as the API might change and is not
* safe if you don't take precautions.
*
* @internal
* @return array message ids
*/
public function search(array $params)
{
$response = $this->requestAndResponse('SEARCH', $params);
if (!$response) {
return $response;
}
foreach ($response as $ids) {
if ($ids[0] == 'SEARCH') {
array_shift($ids);
return $ids;
}
}
return array();
}
最初我认为这可以解决问题...
$storage = new Zend_Mail_Storage_Imap($imap);
$searchresults = $storage->search('search term');
这是错误消息:
可捕获的致命错误:参数 1 传递给 Zend_Mail_Storage_Imap::search() 必须 是一个数组,给定的字符串,称为 在...
但是不,我需要以数组形式发送信息。有什么想法吗?
The following is a function from zend_mail_protocol_imap. i read that to search emails, I would want to override it using zend_mail_storage_imap (which is what I'm using now to grab email from gmail). I copy and pasted the following function into zend_mail_storage_imap, but I'm having issues with the params. I can't find documentation on what to use for the array $params. I initially thought it was the search term before reading it more thoroughly. I'm out of ideas. Here's the function...
/**
* do a search request
*
* This method is currently marked as internal as the API might change and is not
* safe if you don't take precautions.
*
* @internal
* @return array message ids
*/
public function search(array $params)
{
$response = $this->requestAndResponse('SEARCH', $params);
if (!$response) {
return $response;
}
foreach ($response as $ids) {
if ($ids[0] == 'SEARCH') {
array_shift($ids);
return $ids;
}
}
return array();
}
Initially I thought this would do the trick...
$storage = new Zend_Mail_Storage_Imap($imap);
$searchresults = $storage->search('search term');
Here's the error message:
Catchable fatal error: Argument 1
passed to
Zend_Mail_Storage_Imap::search() must
be an array, string given, called
in...
But nope, I need to send the info in an array. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
怎么样
How about
这就是我的做法
zend 的搜索参数与 imap_search 的相同。使用 http://php.net/manual/en/function.imap-search。 php 以供进一步参考。
this is how i did it
Search parameter for zend is same as of imap_search . Use http://php.net/manual/en/function.imap-search.php for further reference .
storage\imap 中(仍然)没有搜索功能,该功能实际上位于协议类中。
要在 storage\imap 中进行搜索,请添加此函数:
现在您应该能够像这样调用
,结果应该是消息的 ids/uids 列表,就像 imap_search 一样。
恕我直言,这个函数或协议的 getter 应该位于存储类中,但事实并非如此。
there is (still) no search function in storage\imap, that function is actually in the protocol class.
to have a search in storage\imap add this function:
now you should be able to call like this
and the result should be a list of ids/uids of the messages, just like imap_search.
imho this function or a getter for protocol should be in the storage class, but it isnt.