I need to find all mails in IMAP mailbox which contains somestring
in BODY and is FROM [email protected]
or TO [email protected]
.
Trying to do:
49:51.53 > JBPM3 SEARCH CHARSET utf-8 "BODY \"somestring\" (OR (TO \"[email protected]\") (FROM \"[email protected]\"))"
Receiving:
49:51.71 < JBPM3 BAD Could not parse command
How to make it work using GMail?
You may skip parenthesis '(' ')' to group logical expressions in IMAP. Parenthesis are not needed in Polish Notation (see edit below):
A0001 SEARCH CHARSET utf-8 BODY "somestring" OR TO "[email protected]" FROM "[email protected]"
You could also use gmail search syntax (X-GM-RAW) command: http://www.limilabs.com/blog/search-gmail-using-gmails-search-syntax
[Edit] Parenthesis are sometimes required in IMAP SEARCH. This is because AND operator can have more than 2 operands and is not explicitly defined: http://www.limilabs.com/blog/imap-search-requires-parentheses