具有多个OR的IMAP条件 [英] IMAP criteria with multiple ORs
问题描述
我正在使用gmail的IMAP API搜索邮件.
I am using gmail's IMAP API to search for mails.
我使用或"条件搜索不同的关键字.如果我仅上一个级别,例如
I use the 'OR' criteria to search for different keywords. This works well if I go one level only, i.e. something like
'UID SEARCH OR (FROM "somebody@email.com") (TO "somebody@email.com")'
但是,当我尝试像
条件或条件或条件或条件
criteria OR criteria OR criteria or criteria
翻译成(据我了解的语法)
which translates to (as far as I understand the syntax)
'UID SEARCH OR ( OR (FROM "somebodyelse@email.com") (TO "somebodyelse@email.com")) ( OR (FROM "somebody@email.com") (TO "somebody@email.com"))'
为了清楚起见,我基本上希望所有从给定电子邮件列表中发送或发送给任何电子邮件列表的消息
to make it clear I basically want all messages that are either sent from or sent to ANY of a given list of emails
我从libray得到的错误是
The error I get from the libray is
[ 'A34', 'BAD', 'Could', 'not', 'parse', 'command' ]
有什么建议吗?
推荐答案
请勿使用括号.
IMAP使用不需要的波兰语表示法:
IMAP uses polish notation which does not need them:
UID SEARCH OR OR FROM one@mail.com TO one@mail.com OR FROM two@mail.com TO two@mail.com
在某些情况下需要括号(因为IMAP AND运算符可以使用两个以上的操作数): https://www.limilabs.com/blog/imap-search-requires-parentheses
There are cases where parenthesis are needed (as IMAP AND operator can take more than 2 operands): https://www.limilabs.com/blog/imap-search-requires-parentheses
这篇关于具有多个OR的IMAP条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!