Skip to content

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.

The protocols differ in age, transport and abilities:

ProtocolSpecificationListener protocolDefault portPage
JMAP for MailRFC 8620, RFC 8621http443 (TLS), 8080JMAP
IMAP4rev2 and IMAP4rev1RFC 9051, RFC 3501imap993 (implicit TLS)IMAP
POP3RFC 1939pop3995 (implicit TLS)POP3
Exchange (MAPI over HTTP, EWS, ActiveSync)Microsoft open specificationshttp443 (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.

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:

JMAPIMAPPOP3Exchange
FoldersYesYesInbox onlyYes
Read and flag state shared between devicesYesYesNoYes
Push of new mailEvent source, WebSocket, Web PushIDLE on one open mailboxNoStreaming notifications, ActiveSync ping
Calendars and contacts in the same accountYesNo (CalDAV and CardDAV)NoYes
Sending mailBuilt inSeparate SMTP submissionSeparate SMTP submissionBuilt in
Typical clientsWebmail, JMAP-native appsMost desktop and mobile clientsLegacy devices and applicationsOutlook, 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.

The protocol settings are held by three singletons, divided by what they govern:

The Exchange protocols have a settings object of their own, described in Exchange configuration.

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.

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.