jordwest/imap-server

Implement `COPY` command

Closed this issue · 0 comments

From the RFC:

Arguments: sequence set, mailbox name
Responses: no specific responses for this command
Result:
OK - copy completed
NO - copy error: can't copy those messages or to that name
BAD - command unknown or arguments invalid

The COPY command copies the specified message(s) to the end of the specified destination mailbox. The flags and internal date of the message(s) SHOULD be preserved, and the Recent flag SHOULD be set,
in the copy.

If the destination mailbox does not exist, a server SHOULD return an error. It SHOULD NOT automatically create the mailbox. Unless it is certain that the destination mailbox can not be created, the server MUST send the response code "[TRYCREATE]" as the prefix of the text of the tagged NO response. This gives a hint to the client that it can attempt a CREATE command and retry the COPY if the CREATE is successful.

If the COPY command is unsuccessful for any reason, server implementations MUST restore the destination mailbox to its state before the COPY attempt.

Example: C: A003 COPY 2:4 MEETING
S: A003 OK COPY completed

Proposal
Flags, headers and body of the message except the UID and sequence numbers MUST be preserved. The UID MUST change to the latest unassigned value for the given mailbox and sequence number will also have the latest value. The server MUST NOT automatically create the target mailbox.