Skip to main content

APPEND

This function appends a message to a folder.

Usage​

const rawMessage = [
"From: [email protected]",
"To: [email protected]",
"Subject: Hello",
"MIME-Version: 1.0",
"Content-Type: text/plain; charset=UTF-8",
"",
"Hello there!",
""
].join("\r\n")

await imap.append("INBOX", rawMessage)

// With flags and an internal date
await imap.append("INBOX", rawMessage, ["Seen"], new Date())
ArgumentTypeDescription
folderstringDestination folder.
messagestring \| Uint8ArrayThe full raw message (headers + body).
flagsstring[]Flags to set on the appended message, e.g. ["Seen"].
internalDateDateInternal date of the message (optional).

The message is sent as an IMAP literal, so it may contain binary data and any line endings.

Response​

When the server reports the assigned UID (the APPENDUID response code), the function returns:

type AppendResult = {
uidValidity: number, // UIDVALIDITY of the destination mailbox
uid: number // UID assigned to the appended message
}

Otherwise it returns null.