What is wrong with this IMAP ESEARCH command synta

2019-07-27 01:35发布

问题:

I am looking for a way to search across all IMAP folders on my mail server. I recently discovered the IMAP ESEARCH command, which extends the usual SEARCH command to search across folders. I cannot, however, seem to make it work.

I have checked that the mail server supports ESEARCH. After telnet-ing in, I executed the following:

* OK JAMES IMAP4rev1 Server Server server-address is ready.
A1 LOGIN test test
A1 OK LOGIN completed.
A2 CAPABILITY
* CAPABILITY SASL-IR IDLE LITERAL+ AUTH=PLAIN CONDSTORE ESEARCH CHILDREN UIDPLUS UNSELECT WITHIN ENABLE I18NLEVEL=1 SEARCHRES IMAP4rev1 NAMESPACE QRESYNC
A2 OK CAPABILITY completed.
A3 LIST "" "*"
* LIST (\HasNoChildren) "." "INBOX"
* LIST (\HasNoChildren) "." "Drafts"
* LIST (\HasNoChildren) "." "Sent"
* LIST (\HasNoChildren) "." "Trash"
A3 OK LIST completed.

Note the presence of ESEARCH. I then tried the following ESEARCH, which fails.

A4 ESEARCH IN (mailboxes "INBOX") unseen
A4 BAD failed. Unknown command.

An ordinary search works fine:

A5 SELECT INBOX
* FLAGS (\Answered \Deleted \Draft \Flagged \Seen)
...
A5 OK [READ-WRITE] SELECT completed.
A6 SEARCH UNSEEN
* SEARCH 3
A6 OK SEARCH completed.

From what I can read of the spec and the formal syntax this should work. Any help or pointers would be much appreciated.

回答1:

That document indicates ESEARCH is described by capability MULTISEARCH.

Capability ESEARCH might be something else?



回答2:

The ESEARCH capability indicates that the server supports RFC 4731 and RFC4466 which defined the ESEARCH reponse and an extended format of the SEARCH command.

The MULTISEARCH capability (RFC 6237) builds upon the ESEARCH capability to make it possible to search in another mailbox than the currently selected one. The command syntax you're using requires MULTISEARCH.



标签: search imap