Copying and moving messages


C: COPY 3-5 8 "" Folders "Sent Mail"
S: * COPY 3 NEWUID=1043320248/3601
S: * COPY 4 NEWUID=1043320248/3602
S: * COPY 5 NEWUID=1043320248/3603
S: * COPY 8 NEWUID=1043320248/3604
S: +OK Messages copied

The COPY command copies messages from the currently open folder to another folder. COPY is followed by whitespace-delimited words that enumerate messages to be copied, an empty word, then whitespace-delimited words that name the folder the messages are copied to.

m-n can be a shortcut designation for messages #m through #n, inclusive. The message number list must be in a numerically-increasing order, with no overlaps.

The server responds with one ore more * COPY single line replies, one reply for each copied message. The next word contains the message number of the copied message, followed by a list of attributes. At present time only one attribute is defined: UID=id gives the assigned unique id of the saved message in the destination folder.


C: MOVE 3-5 8 "" Folders "Sent Mail"
S: * COPY 3 NEWUID=1043320248/3601
S: * COPY 4 NEWUID=1043320248/3602
S: * COPY 5 NEWUID=1043320248/3603
S: * COPY 8 NEWUID=1043320248/3604
S: * EXPUNGE 3-5 8
S: +OK Messages copied

The MOVE command is like COPY except that the messages are moved to the folder, instead of copied. Or, to put it another way, the messages are automatically removed from the current folder after they are copied.

The server also responds with * COPY that indicates messages that were copied to the destination folder; the subsequent * EXPUNGE messages indicate the messages were removed from the original folder.

Note

The server's response to COPY or MOVE may include additional * EXPUNGE, * EXISTS, and * FETCH messages reflecting changes to the folder's contents by other applications that have the same folder opened.

Servers may, but are not required to, notify of other changes to the folder's contents as part of the response to COPY and MOVE.

Note

Servers have several choices for handling requests to copy a message that were removed by another application. A server may handle this situation by doing any one of the following:

  • Respond with an -ERR and do nothing.

  • Copy some or all remaining messages, then report an -ERR.

  • Copy all remaining messages, as if the nonexistent messages were not specified at all by the client's MOVE or COPY.

In all cases the server's response must reflect which messages, if any, were actually copied. It is the user's responsibility to avoid running multiple applications that issue conflicting SMAP requests.