Mail clients
Kantoor serves IMAP, POP3 and SMTP submission itself. All three are off by default: with none of the variables below set, no mail port is opened.
Outgoing mail from a mail client goes through Kantoor's SMTP submission service, which hands every message to Karta; the message is acknowledged only after Karta accepted it. See SMTP submission.
Automatic set-up
If your operator has published the discovery records (DNS records), clients can fill the settings in themselves from your address:
- Thunderbird, Evolution, KMail, K-9: type your address; the server settings are found. Enter an app password when asked.
- iPhone, iPad, Mac: open Settings, App passwords and choose Download an
Apple profile, then install it (Settings, "Profile Downloaded" on iOS; System
Settings, Profiles on macOS). It sets up mail, calendar and contacts with your
address as the user name and asks for an app password; it contains no password
and is unsigned, so the device says "Not Signed". Create the app password first,
with the
imap,smtpanddavscopes. - Outlook: Kantoor answers Outlook's Autodiscover request with IMAP and SMTP settings. Whether Outlook uses it for an account that is not on Exchange depends on the version (and Outlook on the web and some mobile apps never do), so it has not been proven with a real Outlook. If it does not find the server, add the account by hand with the values in the next section (choose IMAP).
The values for your own account
Settings, Mail apps shows the settings for your mailboxes with the host names
and ports this server actually serves, each with a copy button and a "copy all
settings" block. Use that page instead of the mail.example.com examples below
when you set up a client; it also links to the app-password page and the Apple
profile.
Connect Evolution, Thunderbird, DAVx5, iOS and macOS
First make an app password at Settings, App passwords with the scopes the
client needs (imap, smtp and dav; pop3 only for POP3). Every client below
uses the same login: your sign-in email address (or any mailbox address you may
open) and the app password. The examples use mail.example.com; use your own
host name. Give the client the host, or https://mail.example.com/dav/, and it finds the rest
(/.well-known/caldav and /.well-known/carddav answer 301 to /dav/; PROPFIND
on / and on /dav/ answers current-user-principal, calendar-home-set and
addressbook-home-set).
| Client | Calendar, tasks and contacts | |
|---|---|---|
| GNOME Evolution | New account, Collection Account: e-mail address, user name = your address, Look up. Or Mail Account by hand: IMAP mail.example.com, 993, SSL/TLS, password authentication; sending: SMTP mail.example.com, 465, SSL/TLS | Collection Account finds the calendars, the task list and the address book; with Calendar, Task List or Contacts as a separate account choose type CalDAV / CardDAV, URL https://mail.example.com/dav/, user = your address |
| Thunderbird | Account Settings, Add Mail Account: name, address, app password. Autoconfiguration finds IMAP 993 SSL/TLS and SMTP 465 SSL/TLS. By hand: the same values, authentication Normal password | Calendar: New Calendar, On the Network, CalDAV, location https://mail.example.com/dav/, then your address and app password; Thunderbird lists every calendar and task list. Contacts: Address Book, Add CardDAV Address Book, user name = your address, server https://mail.example.com/dav/ |
| DAVx5 (Android) | use K-9 or FairEmail for mail with the IMAP and SMTP values above | Login with URL and user name: base URL https://mail.example.com/dav/, user name = your address, password = the app password. DAVx5 shows each calendar, task list and address book to switch on |
| iPhone, iPad | Settings, App passwords, Download an Apple profile, install it, enter the app password. By hand: Mail, Accounts, Add Account, Other: IMAP mail.example.com 993 SSL, SMTP mail.example.com 465 SSL | in the profile; by hand: Calendar, Accounts, Add Account, Other, Add CalDAV Account, server mail.example.com, user name, password; likewise Add CardDAV Account. |
| macOS (Mail, Calendar, Contacts) | the same profile (System Settings, Profiles), or Internet Accounts, Add Other Account, Mail Account | Internet Accounts, Add Other Account, CalDAV account / CardDAV account, account type Manual, user name, password, server https://mail.example.com/dav/ |
Notes:
- Tasks (VTODO) are kept in the
Taskslist, which is what a task app should be pointed at. TheCalendarcollection takes events and tasks. - A shared calendar appears in the grantee's calendar home as
shared-<id>; a subscribed (external) calendar is read-only over CalDAV. - The default collections are named
Calendar,TasksandContacts. - If a client says the certificate is wrong, the host name you typed is not the one on the certificate; Kantoor never asks a client to trust a certificate.
Which clients were actually exercised, and how (as of 1.0.0, against the live server):
| Client or library | What was run | Result |
|---|---|---|
GNOME Evolution's discovery code (libedataserver, the Look up of a Collection Account) | the real code, with the host and with /.well-known/caldav | found the calendars, the task list, the address book and the user's addresses |
| vdirsyncer 0.21.0 | discover and two-way sync of every calendar, the task list and the address book against the live server; a local event, task and card uploaded, a server edit pulled down, local deletes propagated | worked |
| isync/mbsync 1.4.4 (Alpine container) | pull of INBOX, Sent, Drafts and sub-folders over IMAPS, a locally written message pushed back | worked |
Python imaplib, poplib, smtplib, requests | every IMAP, POP3, SMTP and DAV operation of the 1.0 inventory | worked |
| Thunderbird, DAVx5 | not run. The requests each is documented to make (RFC 6764 .well-known, OPTIONS, PROPFIND for current-user-principal, the home sets, calendar-user-address-set, supported-calendar-component-set, getctag, sync-token, then sync-collection and multiget) were replayed by script, and every answer was checked | all 33 checks passed |
| iOS, macOS, Outlook, K-9 | not run, not replayed; the steps above follow their documentation | unverified |
Before a client can connect
- Enable the protocols on the server and choose their ports (see Installing Kantoor).
- Configure a TLS certificate, or put the ports behind a TCP proxy that terminates TLS and sends the PROXY protocol.
- Create an app password for each device in Settings, App passwords with
the
imap,pop3orsmtpscope. The password is shown once; it cannot be read back. It can be given an expiry date and revoked at any time.
The login is the user's sign-in email address, or the address of any mailbox
that user may open. The password is the app password. There is no
user+tag or user*mailbox syntax.
Failed logins are rate limited per IP and login. A throttled login is
answered NO [UNAVAILABLE] over IMAP and -ERR [SYS/TEMP] over POP3.
Client settings
The values below assume the public host name mail.example.com. Use the
ports you enabled.
| Setting | IMAP | POP3 |
|---|---|---|
| Server | mail.example.com | mail.example.com |
| Implicit TLS port | 993 | 995 |
| STARTTLS/STLS port | 143 | 110 |
| User name | your sign-in email or a mailbox address | same |
| Password | an app password with the imap scope | an app password with the pop3 scope |
| Security | SSL/TLS (993) or STARTTLS (143) | SSL/TLS (995) or STLS (110) |
Inside the container the listeners use unprivileged ports: 1143 (IMAP plain)
and 1993 (IMAPS) by default, 1110 (POP3 plain) and 1995 (POP3S). Map them to
the standard ports outside the container, or change them with
KANTOOR_IMAP_PORT, KANTOOR_IMAPS_PORT, KANTOOR_POP3_PORT and
KANTOOR_POP3S_PORT.
Plain-text authentication is refused unless the connection is already
encrypted and KANTOOR_IMAP_ALLOW_PLAINTEXT_AUTH or
KANTOOR_POP3_ALLOW_PLAINTEXT_AUTH is set. Leave those off.
SMTP submission
When both ports are published, Settings, Mail apps shows both with the same user name and app password. Thunderbird and Outlook discovery include both. The default Apple profile retains the primary SMTP option; Apple profile with STARTTLS selects port 587 without adding a duplicate mail account.
| Setting | Value |
|---|---|
| Server | mail.example.com |
| Port and security | 465 with SSL/TLS, or 587 with STARTTLS |
| Authentication | normal password (PLAIN or LOGIN) |
| User name | your sign-in email or a mailbox address (the same as for IMAP) |
| Password | an app password with the smtp scope |
Evolution, Thunderbird, iOS Mail and K-9 accept these
values. The server is KANTOOR_SMTP_ENABLED=true; inside the container it listens on
1587 (STARTTLS) and 1465 (implicit TLS) unless KANTOOR_SMTP_PORT and
KANTOOR_SMTPS_PORT say otherwise. Behind a TLS-terminating TCP proxy only the
465 route is offered (see the deploy notes).
Rules a client meets:
- Login is required before
MAIL FROM, andAUTHis only offered after TLS (STARTTLSor port 465) unlessKANTOOR_SMTP_ALLOW_PLAINTEXT_AUTHis set. Failures are answered535without saying why, a throttled login454. - The envelope sender and every address in the
From(andSender) header must be the address of a mailbox the user may open, else553 5.7.1. A message needs exactly oneFromheader.DateandMessage-IDare added when missing. - Extensions:
PIPELINING,SIZE(25 MiB by default),8BITMIME,ENHANCEDSTATUSCODES,STARTTLS,AUTH PLAIN LOGIN. Lines of the message may be 998 bytes, as RFC 5321 says; line endings must be CRLF. - Up to 200 messages per user and 400 per client IP per hour, 100 recipients per
message; beyond that
450/452. - If Karta cannot take the message the answer is
451(try again later; the client keeps it queued) or, when Karta refused this particular message,554. Too large is552. - Kantoor does not store a copy: clients save their own in Sent over IMAP.
KANTOOR_SMTP_SAVE_SENT=truestores one in the Sent folder as webmail does (it would duplicate the client's own copy).
IMAP
The server advertises exactly what it implements:
IMAP4rev1 LITERAL+ SASL-IR ID ENABLE IDLE NAMESPACE UIDPLUS MOVE UNSELECT
CHILDREN SPECIAL-USE LIST-EXTENDED LIST-STATUS CONDSTORE QRESYNC ESEARCH
SORT THREAD=ORDEREDSUBJECT THREAD=REFERENCESSTARTTLS, LOGINDISABLED and AUTH=PLAIN are added depending on the
connection and its TLS state.
- QRESYNC (RFC 7162):
ENABLE QRESYNC,SELECTwithQRESYNC, andUID FETCH ... (CHANGEDSINCE n VANISHED)are supported. Expunges are recorded as tombstones so an offline client can resynchronise; a client whose modification sequence is older than the retained tombstone floor is answered with the full set of UIDs that are not visible now. - ESEARCH (RFC 4731):
SEARCH RETURN (MIN MAX ALL COUNT).SAVE(SEARCHRES) is not supported. - SORT (RFC 5256): ordered in SQL over the index, with
ARRIVAL,CC,DATE,FROM,SIZE,SUBJECTandTO, andREVERSE.DISPLAYFROM/DISPLAYTO(RFC 5957) are not offered. - THREAD (RFC 5256):
ORDEREDSUBJECTandREFERENCES, built from the storedMessage-ID,ReferencesandIn-Reply-Toheaders.
Other limits: the largest APPEND is 25 MiB by default
(KANTOOR_IMAP_MAX_MESSAGE_BYTES), the command line is 8 KiB, a non-APPEND
literal is 64 KiB, a login must finish within 60 seconds, an idle connection
is closed after 30 minutes, and 20 consecutive bad commands or 5 failed
logins end the connection.
POP3
POP3 exposes INBOX only. The default delete mode is mark: QUIT adds the
keyword $POP3Downloaded and keeps the mail. With
KANTOOR_POP3_DELETE_MODE=delete, QUIT expunges what the client marked
with DELE. Mail held over quota is invisible to POP3.
A POP3 connection is closed after 10 minutes of idleness.
Connection limits
The defaults are 200 simultaneous connections per protocol and 20 per client
IP (an IPv6 client is counted per /64). Both are configurable with
KANTOOR_MAIL_MAX_CONNECTIONS and KANTOOR_MAIL_MAX_CONNECTIONS_PER_IP.
If a TCP proxy terminates TLS, set KANTOOR_MAIL_PROXY_TRUSTED to the proxy
network and KANTOOR_MAIL_PROXY_TLS=true; Kantoor then reads the real client
address from the PROXY protocol header and treats the connection as already
encrypted. A peer inside the trusted list must send the header or it is
refused. Do not publish the plain listener ports on the host.
Testing the connection
From outside the server, check the certificate and log in:
openssl s_client -connect mail.example.com:993
a1 LOGIN you@example.com <app password>The app password's last-used address, shown in Settings, App passwords, must be your own address, not a proxy's.