Overview
Once mail has been delivered, users need to read it, sort it and keep it in step across their devices. Mail clients do this through an access protocol: JMAP, IMAP or POP3, or one of the Microsoft Exchange protocols for clients built for Exchange. This section describes how Stalwart serves each of them, the mailboxes and messages they operate on, and the limits that apply.
Two related tasks are covered elsewhere. Sending mail uses SMTP submission, which is part of the MTA. Users manage their own Sieve filters through ManageSieve or JMAP for Sieve.
Every protocol operates on the same mailboxes and messages; none keeps a copy of its own. A message filed by one client is therefore visible at once to every other client of the account, whichever protocol each one uses. Mailboxes, messages and flags describes the model they share and how each protocol presents it.
Protocols
Section titled “Protocols”The protocols differ in age, transport and abilities:
| Protocol | Specification | Listener protocol | Default port | Page |
|---|---|---|---|---|
| JMAP for Mail | RFC 8620, RFC 8621 | http | 443 (TLS), 8080 | JMAP |
| IMAP4rev2 and IMAP4rev1 | RFC 9051, RFC 3501 | imap | 993 (implicit TLS) | IMAP |
| POP3 | RFC 1939 | pop3 | 995 (implicit TLS) | POP3 |
| Exchange (MAPI over HTTP, EWS, ActiveSync) | Microsoft open specifications | http | 443 (TLS) | Microsoft Exchange |
JMAP (JSON Meta Application Protocol) is the most recent. A client sends batches of JSON method calls over HTTP, synchronises by asking for the changes since a state it already knows, and receives push notifications of changes. One JMAP session covers mail, calendars, contacts and files.
IMAP is the established protocol for keeping mailboxes in step between a server and desktop or mobile clients. It holds a connection open per client, and offers folders, flags, server-side search and, with its extensions, incremental synchronisation and push for the open mailbox.
POP3 is far simpler. It downloads the messages in the inbox and, optionally, deletes them from the server. It has no folders, and keeps no state that a second device could share.
The Exchange protocols serve clients built for Microsoft Exchange: classic Outlook, Apple’s Exchange accounts and the mail apps of mobile devices. They are disabled until the administrator enables them.
Choosing a protocol
Section titled “Choosing a protocol”The client usually decides which protocol is used, but the administrator decides which protocols are offered, and the differences matter when users ask why a feature works on one device and not on another:
| JMAP | IMAP | POP3 | Exchange | |
|---|---|---|---|---|
| Folders | Yes | Yes | Inbox only | Yes |
| Read and flag state shared between devices | Yes | Yes | No | Yes |
| Push of new mail | Event source, WebSocket, Web Push | IDLE on one open mailbox | No | Streaming notifications, ActiveSync ping |
| Calendars and contacts in the same account | Yes | No (CalDAV and CardDAV) | No | Yes |
| Sending mail | Built in | Separate SMTP submission | Separate SMTP submission | Built in |
| Typical clients | Webmail, JMAP-native apps | Most desktop and mobile clients | Legacy devices and applications | Outlook, Apple Exchange accounts, mobile mail apps |
IMAP remains the protocol most clients use, and it is the right default. JMAP suits webmail and clients built for it, because a single HTTP connection handles mail, calendars and contacts and pushes changes for the whole account. POP3 suits only devices and applications that support nothing else, since it gives a single device a copy of the inbox and nothing more. The Exchange protocols are worth enabling where Outlook or Apple’s Exchange account type is in use, as they give those clients mail, calendars and contacts through one account.
Settings
Section titled “Settings”The protocol settings are held by three singletons, divided by what they govern:
- Jmap holds the JMAP request and push limits, described in JMAP limits.
- Imap holds the IMAP settings, and also governs POP3 and ManageSieve sessions, as described in IMAP and Session limits.
- Email holds what applies to messages and mailboxes whichever protocol is used: the default folders and the message and mailbox limits.
The Exchange protocols have a settings object of their own, described in Exchange configuration.
Listeners
Section titled “Listeners”Each protocol is served by a NetworkListener, found in the WebUI under Settings › Network › Listeners. The listener’s protocol field selects the protocol. A new installation has listeners for HTTP on ports 443 and 8080, IMAP on 993, POP3 on 995, ManageSieve on 4190, and SMTP on 25 and 465. JMAP and the Exchange protocols are served by the HTTP listeners, the same ones that serve the WebUI, so they need no listener of their own.
The cleartext ports 143 and 110 are the exception: their listeners are not created by default. The following objects add them. Clients connecting to these ports must upgrade the connection with STARTTLS (IMAP) or STLS (POP3) before they can authenticate, unless allowPlainTextAuth is enabled:
[ {"name": "imap", "protocol": "imap", "bind": {"[::]:143": true}}, {"name": "pop3", "protocol": "pop3", "bind": {"[::]:110": true}}]A listener with implicitTls set to true starts TLS as soon as the connection is opened, as on ports 993 and 995. Listeners describes the other fields.
A protocol that an installation does not need can be removed. POP3, for example, is removed by deleting its listener. JMAP, IMAP and POP3 access can also be withdrawn per account rather than per server, by removing the protocol’s permissions from a role, as each protocol page describes.
Search and metadata
Section titled “Search and metadata”Searches issued over IMAP and JMAP cover the text of attachments as well as the message body. When Stalwart indexes a message, it extracts the text of common document formats, and searches use that text. Attachment text extraction lists the formats and limits.
Clients can also store annotations of their own. Annotations that IMAP clients store with the METADATA extension, and the equivalent JMAP and WebDAV properties, are described in Object metadata.