How can I use the Conditional OR to search emails with imap_search - PHP IMAP library

后端 未结 2 1746
醉酒成梦
醉酒成梦 2021-01-24 00:06

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

I found that a condition OR is not supported in this library. Imap_search Bug Report Link There has to be a w

2条回答
  •  情歌与酒
    2021-01-24 00:08

    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"'.

    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.

提交回复
热议问题