Message and mailbox limits
A message with a huge header, or a message filed in hundreds of mailboxes, is costly for the server to parse, index and synchronise to every client. Stalwart therefore bounds the size and shape of the messages and mailboxes it stores, so that a single client or sender cannot create such objects.
The limits apply to every access protocol. A message appended over IMAP, created or imported over JMAP, or received over SMTP is checked against the same values. They are set on the Email singleton, found in the WebUI under Settings › Email › Defaults, Settings › Email › Encryption, Settings › Email › Limits, Settings › Email › Storage.
Message size
Section titled “Message size”Two fields bound the size of what is stored, one for the whole message and one for each attachment:
| Field | Default | Limit |
|---|---|---|
maxMessageSize | 75 MB | Size of a whole message stored in a mailbox. |
maxAttachmentSize | 50 MB | Size of a single attachment. |
Mail received over SMTP meets another limit first. The SMTP server applies its own message size limit before a message reaches a mailbox, and that limit is configured on the DATA stage.
A related limit lives elsewhere. The number of messages that a single JMAP Email/parse request may parse is a JMAP protocol limit, parseLimitEmail on the Jmap singleton, described with the other JMAP limits.
Header section
Section titled “Header section”The top-level header section has limits of its own:
| Field | Default | Limit |
|---|---|---|
maxHeaderSize | 512 KiB, minimum 1 KiB | Size in bytes of the top-level header section. |
maxHeaderCount | 5000, minimum 100 | Number of header fields in the top-level header section. |
Both limits apply to the header section of the message itself, not to the headers of its MIME parts. A third limit is fixed: independently of these settings, a message may not carry more than 65534 header fields across all of its parts. A message that exceeds any of the three limits is refused, in the way of the protocol that carried it:
- JMAP
Email/setandEmail/importreturn atooLargeerror. - IMAP
APPENDfails with a taggedNO [LIMIT]response. - SMTP refuses the message at the end of
DATA, on both the MX and the submission ports, with the reply listed in Message limits. Messages that Stalwart generates itself are not checked.
The description of the error names the limit that was exceeded, for example An email header cannot exceed <n> bytes. or An email header cannot have more than <n> fields.
Mailboxes and flags per message
Section titled “Mailboxes and flags per message”A message can carry metadata of its own: the mailboxes it belongs to and the flags set on it. Each is bounded:
| Field | Default | Limit |
|---|---|---|
maxMailboxesPerEmail | 100 | Number of mailboxes a single message can belong to. JMAP allows a message to be in several mailboxes at once; IMAP clients see each membership as a copy. |
maxFlagsPerEmail | 100 | Number of flags on a single message. JMAP keywords and IMAP flags are the same values, so the limit covers both. |
maxFlagLength | 128 bytes, maximum 1024 | Length of a single flag or keyword name. System flags such as \Seen are exempt from this check. |
These limits prevent growth only. An operation that leaves a message with fewer mailboxes or flags than before is always accepted. A message that already exceeds a lowered limit can therefore still be cleaned up. An operation that would push a message over a limit fails as follows:
| Limit | JMAP Email/set | IMAP |
|---|---|---|
| Mailboxes per message | tooManyMailboxes on mailboxIds | NO [LIMIT] An email cannot belong to more than <n> mailboxes. |
| Flags per message | tooManyKeywords on keywords | NO [LIMIT] An email cannot have more than <n> keywords. |
| Flag length | invalidProperties on keywords | NO [LIMIT] Keywords cannot be longer than <n> bytes. |
Mailbox hierarchy
Section titled “Mailbox hierarchy”Mailboxes themselves are bounded in depth and in the length of their names:
| Field | Default | Limit |
|---|---|---|
maxMailboxDepth | 10 | Nesting depth of a mailbox below the account’s top level. |
maxMailboxNameLength | 255 | Length of a single mailbox name. |
The following object body lowers the mailbox depth and the number of mailboxes a message may belong to:
{ "maxMailboxDepth": 6, "maxMailboxesPerEmail": 20}Per-account object quotas
Section titled “Per-account object quotas”Besides the shape of individual objects, the server bounds how many objects an account can create. The Email singleton holds the default number of objects of each type. Each default applies to accounts that have no value of their own in their quotas map. Quotas describes how the per-account values override them.
| Field | Default | Objects counted |
|---|---|---|
maxMessages | unlimited | Messages |
maxMailboxes | 250 | Mailboxes |
maxIdentities | 20 | JMAP sending identities |
maxSubmissions | 500 | JMAP email submissions |
maxMaskedAddresses | 5 | Masked addresses (Enterprise edition) |
maxPublicKeys | 5 | Public keys for encryption at rest |
The remaining fields of the singleton control how messages are stored. compressionAlgorithm selects the compression applied to stored message data. encryptAtRest and encryptOnAppend are described in Encryption at rest. The default folders created for new accounts are described in IMAP and POP3.