Skip to content

POP3

POP3 (RFC 1939) is the oldest and simplest of the access protocols. A client connects, lists the messages in the inbox, downloads the ones it has not seen, optionally deletes them from the server, and disconnects. There are no folders, no flags and no notifications, and nothing a POP3 client does is visible to the user’s other devices except deletion. Stalwart offers POP3 for devices and applications that support nothing else. Users with a choice should use IMAP or JMAP.

POP3 is served by a NetworkListener with the pop3 protocol, on port 995 with implicit TLS in a new installation, as described in the protocol overview. An installation without POP3 clients can delete that listener.

A POP3 session sees the inbox of the account that signed in, and nothing else. Other folders, and mailboxes that other accounts share with the user, are not reachable. A message that a Sieve script or a client has filed elsewhere is therefore invisible to POP3, even though it is in the account.

The list of messages is taken once, when the client authenticates, and does not change for the rest of the session. Mail that arrives while the session is open appears in the next session. The messages are numbered in the order of their UIDs, which is the order in which they reached the inbox.

An administrator can open another account’s inbox through a master-user sign-in, giving the user name as <target>%<administrator> together with the administrator’s own password. The administrator needs the impersonate permission, as described in Impersonation.

POP3 clients that leave mail on the server recognise the messages they have already downloaded by their unique identifiers, returned by the UIDL command. Stalwart builds each identifier from the inbox’s UIDVALIDITY followed by the message’s IMAP UID in that inbox, both in decimal, so a message keeps the same identifier for as long as it stays in the inbox.

The identifiers change only if the inbox’s UIDs are reassigned, which happens when an administrator runs the account maintenance task that recalculates IMAP UIDs, as described in Message UIDs. Every message then has a new identifier, and a client that leaves mail on the server downloads the whole inbox again.

A client deletes messages with DELE, and the deletion is deferred. DELE only marks a message, RSET clears every mark, and the marked messages are removed when the client ends the session with QUIT. A session that ends in any other way, because the connection drops, the session times out or the server shuts down, removes nothing, and the client can try again in its next session.

Removal over POP3 is permanent and applies to the whole account. The message is destroyed, not moved to the Trash folder, and it disappears from every folder it was filed in, since POP3 has no notion of folders to remove it from one only. Its size is credited to the account’s quota at once. When the deleted-item archive is enabled with archiveDeletedItemsFor, the message is archived and can be recovered, as for messages expunged over IMAP; see Mail retention.

The reply to QUIT reports the result, for example +OK Stalwart POP3 bids you farewell (3 messages deleted). When some messages could not be removed, for example because another session had removed them first, the reply is -ERR Some messages could not be deleted. The messages that could be removed are removed regardless.

Within a session, Stalwart departs from RFC 1939 in one respect: messages marked with DELE are still listed by LIST and UIDL, can still be retrieved, and are still counted by STAT. STAT reports the totals taken at sign-in throughout the session.

RETR returns a whole message and TOP returns its header followed by a given number of body lines. Neither changes the message: unlike an IMAP fetch, retrieving a message over POP3 does not mark it as read for the user’s other clients.

The size that LIST and STAT report is the size of the stored message. The octet count in the RETR reply is the size actually sent, after line endings are normalised to CRLF and lines beginning with a dot are escaped, and it can therefore be slightly larger. When a message has been removed by another session after the list was taken, RETR fails with -ERR Failed to fetch message. Perhaps another session deleted it?

The server lists its extensions in the reply to CAPA (RFC 2449). The following are always listed:

  • TOP and UIDL, the optional commands of RFC 1939
  • RESP-CODES, for response codes such as [SYS/TEMP] in error replies
  • PIPELINING, so a client may send several commands without waiting for each reply
  • EXPIRE NEVER, since the server never removes messages on its own because they were downloaded
  • UTF8 (RFC 6856), accepted after authentication and answered with +OK UTF8 enabled
  • IMPLEMENTATION Stalwart Server

Three further entries depend on the connection. STLS (RFC 2595) is listed on a cleartext connection. USER and SASL are listed only where the client may authenticate, which is on TLS connections or where cleartext authentication is allowed, as the next section describes.

Clients authenticate with USER and PASS, or with AUTH (RFC 5034) and one of these SASL mechanisms:

  • PLAIN, for a password
  • OAUTHBEARER (RFC 7628) and XOAUTH2, for an OAuth access token or an API key carrying the mail scope, offered on TLS connections only

APOP, AUTH LOGIN and the challenge-response mechanisms are not supported. APOP is answered with -ERR APOP not supported., and AUTH LOGIN with -ERR Unsupported mechanism 'LOGIN'.

Authentication follows the rules shared with IMAP and ManageSieve, described in IMAP authentication. On a cleartext connection without allowPlainTextAuth, every login command is answered with -ERR Cannot authenticate over plain-text., and the client must first upgrade the connection with STLS.

POP3 has no way to ask for a second factor. An account with two-factor authentication enabled receives -ERR This account requires multi-factor authentication. Alternatively, you can use an app password if your account has one. after a correct password, and must sign in with an app password instead.

Every other failure, whether an unknown user, a wrong password or a malformed SASL response, is answered with the same -ERR Authentication failed, so that the reply reveals nothing about the account. After maxAuthFailures failures in one session the next one is answered with -ERR Too many authentication attempts, and the server disconnects.

POP3 has no settings object of its own. The settings it obeys are fields of the Imap singleton, found in the WebUI under Settings › Network › IMAP, and they apply to IMAP and POP3 alike:

  • allowPlainTextAuth and maxAuthFailures, described in Authentication
  • anonymousTimeout for a session that has not authenticated and authenticatedTimeout for one that has; a session that stays silent for longer receives -ERR Connection timed out. and is closed
  • maxConcurrentConnections and rateLimit, the per-account limits described in Session limits

The session limits count POP3, IMAP and ManageSieve sessions together. A login that would exceed the number of concurrent sessions is answered with -ERR [SYS/TEMP] Too many concurrent requests, and a command over the request rate with -ERR [SYS/TEMP] Too many requests, retry in <n> seconds. In both cases the server then closes the connection, since POP3 offers no way to refuse a command and keep the session. The request rate counts the commands that read or change the mailbox, not the login commands.

The other fields of the Imap singleton concern IMAP commands and have no effect on POP3.

Each POP3 command that reads or changes the mailbox is governed by a permission: pop3Authenticate to sign in at all, then pop3List, pop3Uidl, pop3Stat, pop3Retr (for RETR and TOP) and pop3Dele. Removing pop3Authenticate from a role withdraws POP3 from its users without affecting their other protocols.

A client that issues a command it lacks the permission for receives no reply: the server closes the connection, and the missing permission is recorded only in the server log. A POP3 client that disconnects immediately after signing in or after a particular command is therefore worth checking against the account’s permissions.