1

I have a testing email with the following Subject:

this's is a "TEST" of "quote's"

I'm trying to find the correct string to give the IMAP SEARCH call so that it will find that email. I am running into trouble because the syntax for a multi-word phrase is:

SEARCH SUBJECT "multi-word phrase"

However, the double-quote in the Subject string breaks that.

How should I escape the double-quotes in the sample subject so that the response is not empty?

My server is running Dovecot on CentOS 7, and my client is using PHP's imap calls.

RedDwarfian
  • 111
  • 2

2 Answers2

2

You can use the string Literal format (as opposed to Quoted format)

01 SEARCH SUBJECT {21}
<Wait for server to acknowledge>
this's is a "TEST" of "quote's"

https://www.rfc-editor.org/rfc/rfc3501#section-4.3

A literal is a sequence of zero or more octets (including CR and
LF), prefix-quoted with an octet count in the form of an open brace ("{"), the number of octets, close brace ("}"), and CRLF. In the case of literals transmitted from server to client, the CRLF is immediately followed by the octet data. In the case of literals transmitted from client to server, the client MUST wait to receive a command continuation request (described later in this document) before sending the octet data (and the remainder of the command).

Theo Belaire
  • 421
  • 4
  • 6
0

When I talked to a Dovecot server from the command line, escaping the double quote with a backslash returned the right result for me: S SEARCH SUBJECT "\"".

Kaspar Etter
  • 101
  • 2