title: What is wrong with this IMAP ESEARCH command syntax?
body: <p>I am looking for a way to search across all IMAP folders on my mail server. I recently discovered the <a href="https://www.rfc-editor.org/rfc/rfc6237#section-2" rel="nofollow noreferrer">IMAP ESEARCH command</a>, which extends the usual SEARCH command to search across folders. I cannot, however, seem to make it work.</p>
  <p>I have checked that the mail server supports <code>ESEARCH</code>. After telnet-ing in, I executed the following:</p>
  <pre><code>* 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 &quot;&quot; &quot;*&quot;
  * LIST (\HasNoChildren) &quot;.&quot; &quot;INBOX&quot;
  * LIST (\HasNoChildren) &quot;.&quot; &quot;Drafts&quot;
  * LIST (\HasNoChildren) &quot;.&quot; &quot;Sent&quot;
  * LIST (\HasNoChildren) &quot;.&quot; &quot;Trash&quot;
  A3 OK LIST completed.
  </code></pre>
  <p>Note the presence of <code>ESEARCH</code>. I then tried the following <code>ESEARCH</code>, which fails.</p>
  <pre><code>A4 ESEARCH IN (mailboxes &quot;INBOX&quot;) unseen
  A4 BAD failed. Unknown command.
  </code></pre>
  <p>An ordinary search works fine:</p>
  <pre><code>A5 SELECT INBOX
  * FLAGS (\Answered \Deleted \Draft \Flagged \Seen)
  ...
  A5 OK [READ-WRITE] SELECT completed.
  A6 SEARCH UNSEEN
  * SEARCH 3
  A6 OK SEARCH completed.
  </code></pre>
  <p>From what I can read of the spec and the <a href="https://www.rfc-editor.org/rfc/rfc6237#section-4" rel="nofollow noreferrer">formal syntax</a> this should work. Any help or pointers would be much appreciated.</p>