Default folders
Mail clients look for certain folders by purpose rather than by name: where to put sent mail, where deleted messages go, where spam lands. These are special-use folders, and the server tells clients which folder serves which purpose. IMAP clients learn it from the special-use attributes in LIST responses (RFC 6154), JMAP clients from the role property of each mailbox. A client that finds a Sent folder this way files sent mail there instead of creating a folder of its own.
When an account is created, Stalwart creates the special-use folders listed in defaultFolders on the Email singleton. The folders are created by the server, not by the first client to connect, so every client of the account sees the same set from the start. The setting is found in the WebUI under Settings › Email › Defaults.
Folder definitions
Section titled “Folder definitions”The field is a map keyed by special-use type: inbox, trash, junk, drafts, archive, sent, shared, important, memos, scheduled and snoozed. Each entry has the following fields:
| Field | Default | Meaning |
|---|---|---|
name | required | Display name of the folder. |
create | true | Whether the folder is created for new accounts. The inbox, the trash and the junk folder are always created. |
subscribe | true | Whether new accounts are subscribed to the folder. |
aliases | none | Other names by which IMAP clients can refer to the folder. |
Five folders are created even without an entry. When the map has no entry for the inbox, the trash, the junk folder, drafts or sent mail, that folder is created as Inbox, Deleted Items, Junk Mail, Drafts or Sent Items. The following object body renames the Sent and Junk folders, and leaves the Junk folder unsubscribed:
{ "defaultFolders": { "sent": {"name": "Sent", "subscribe": true}, "junk": {"name": "Spam", "subscribe": false}, "shared": {"name": "Shared Folders"} }}The setting applies when an account is created. Accounts that already exist keep their folders, and users may rename them later like any other folder.
Aliases
Section titled “Aliases”Not every IMAP client honours special-use attributes. Some look for a folder by a fixed name, such as Sent Messages, and mail then ends up split between that folder and the one other clients use. Aliases join the two. When an account has a folder whose name matches an alias, IMAP clients see that name as the special-use folder itself: the entry carries the special-use attribute in LIST, and selecting it, appending to it or copying into it reaches the special-use folder. An alias resolves only through a folder of that name: an alias for which the account has no folder is neither listed nor accepted.
The following object body makes Sent Messages and Sent Mail refer to the Sent folder:
{ "defaultFolders": { "sent": {"name": "Sent Items", "aliases": ["Sent Messages", "Sent Mail"]} }}Shared folder
Section titled “Shared folder”The shared entry is different from the others. It does not create a folder: it names the virtual folder under which IMAP clients see the mailboxes that other accounts share with the user, as described in Shared mailboxes. JMAP clients do not use it, since JMAP presents each shared account separately.