is EXPUNGE allowed in IMAP APPEND command

210 Views Asked by At

Is this an allowed "response" to an IMAP APPEND command? Sometimes the mailserver where I want to upload some messages responds this way and my current implementation does to allow the EXPUNGE.

A00003 APPEND "somefolder" (\Seen) "12-Dec-2012 12:12:12 +0000" {1212}
* 1 EXPUNGE
* 18 EXISTS
* 18 RECENT
+ send APPEND data...

What I have:

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

An EXPUNGE response MUST NOT be sent when no command is in progress, nor while responding to a FETCH, STORE, or SEARCH command.

Also:

A command is not "in progress" until the complete command has been received; in particular, a command is not "in progress" during the negotiation of command continuation.

I am not able to put the pieces together.

1

There are 1 best solutions below

6
On BEST ANSWER

The server is behaving incorrectly. It should not send EXPUNGE and then the + continuation. That said, this rule

in particular, a command is not "in progress" during the
negotiation of command continuation

is a bit little senseless and I would not trust random servers to obey it.

I can guess why the rule exists. In a command like the one below, the meaning of 3:7 depends on which EXPUNGE responses the client has parsed and acted on before it constructed the string 3:7:

a uid search subject {3}
foo
3:7

But the server has to deal with MSNs. Clients can generally choose to avoid the whole problem area by using UIDs instead of MSNs.

My suggestion is to avoid sending MSNs, to use UIDs always, and to be as tolerant as you can of oddly timed EXPUNGE responses.