Correct format for IMAP "SEARCH" command

I have two IMAP SEARCH commands. Can anyone please tell me which one of these is formatted correctly, or if indeed they both are:

Search A:

UID SEARCH NOT DELETED (OR FROM "eBay" (OR SUBJECT "eBay" (OR TO "eBay" (OR CC "eBay" BODY "eBay"))))

Search B:

UID SEARCH (OR FROM "eBay" (OR SUBJECT "eBay" (OR TO "eBay" (OR CC "eBay" BODY "eBay")))) NOT DELETED

One returns the correct results from my inbox, but the other does not. I'm trying to work out if my mail server software is at fault, or the client issuing the command.

Thanks


Those are equivalent ways to express the same search. Both are correct and any correct server should return the same set of messages for both searches.

Somewhat simplified, the following two are different ways to express "tell me which messages have not been read and are about subject ebay":

s1 uid search subject "ebay" unseen
s2 uid search unseen subject "ebay"

A and B is the same as B and A.