如何使用条件OR来通过imap_search搜索电子邮件-PHP IMAP库 [英] How can I use the Conditional OR to search emails with imap_search - PHP IMAP library

查看:270
本文介绍了如何使用条件OR来通过imap_search搜索电子邮件-PHP IMAP库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在imap_search()命令中使用OR语句.

I need to use an OR statement in an imap_search() command.

我发现此库不支持条件OR. Imap_search错误报告链接必须有一种方法可以搜索电子邮件使用条件或,我将如何去做呢?我不确定该从哪里开始.

I found that a condition OR is not supported in this library. Imap_search Bug Report Link There has to be a way that I can search through the email using a conditional OR, how would I go about doing it? I'm not sure where I'd start.

我想做的事:

$boxes = imap_search($connection,'SINCE "08-Mar-2011" AND (BODY "bobby" OR BODY "robert" OR BODY "bob"');

推荐答案

您的SEARCH语法错误,因为运算符为前缀而不是前缀.正确的搜索字符串应为'SINCE "08-Mar-2011" OR BODY "bobby" OR BODY "robert" BODY "bob"'.

Your SEARCH syntax is wrong, as the operators are prefix and not infix. The correct search string should be 'SINCE "08-Mar-2011" OR BODY "bobby" OR BODY "robert" BODY "bob"'.

但是,如果PHP仅不支持imap_search中的OR -并且您的链接表明它们不支持,尽管c-client支持了将近10年了–那么您就必须这样做您的应用程序中的条件或.运行

But if PHP simply doesn't support OR in imap_search -- and your link indicates that they don't, despite c-client support for it for almost 10 years -- then you'll have to do the conditional OR in your application. Run

$box_bobby  = imap_search($connection, 'SINCE "08-Mar-2011" BODY "bobby"');
$box_robert = imap_search($connection, 'SINCE "08-Mar-2011" BODY "robert"');
$box_bob    = imap_search($connection, 'SINCE "08-Mar-2011" BODY "bob"');

,然后合并三个结果集.

and then merge the three result sets.

这篇关于如何使用条件OR来通过imap_search搜索电子邮件-PHP IMAP库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆