Skip to content

Groupware

github-actions[bot] edited this page Dec 4, 2026 · 1 revision

Groupware

How OwnMail gives teams what they would otherwise use Exchange for, as far as open protocols carry it: shared mailboxes, sending as or on behalf of them, distribution groups, filters and out-of-office, calendars and address books that sync and can be shared, a company directory, invitations, free/busy, rooms, and access for AI programs. It builds on the mail service described in Architecture and follows the same rules: written in Go on top of libraries, inside the mail service, no ready-made groupware product. How people use it is in Usage.

It all works with standard programs: Thunderbird, Apple Mail/Calendar/Contacts, iOS, Android with DAVx5, and Outlook with limits. Exchange's own protocols are not in scope (see Not doing).

All of this was designed and built in an earlier program and moved here with the mail service, in phases G1 to G7:

Phase Content Status
G1 Mailbox accounts: display name, account API, app passwords, organisations built
G2 Filters and out-of-office (Sieve, ManageSieve) built
G3 Shared mailboxes, send as / on behalf, distribution groups built
G4a Calendars and contacts, discovery, sync, directory built
G4b Sharing calendars and address books built
G5a Free/busy, invitations to and from outside built
G5b Scheduling between mailboxes, rooms and equipment built
G7 AI programs per mailbox (MCP, OAuth) built
G6 Webmail, web calendar and contacts not built

Decisions

  1. The mailbox is the person. There is no user directory besides the mailboxes. A personal mailbox (anna@example.com) is the identity for everything: IMAP, DAV, sharing, the account API, AI access. Sign-in is always the full address. Mailboxes have a display name, which invitations, out-of-office replies and the directory use.
  2. The sharing boundary is the organisation. By default every mail domain is its own organisation. Administrators group several domains into one organisation, for example a company with example.com and example.de. Grants, delegation, calendar and address-book sharing, free/busy and the directory never cross an organisation. Administrators cannot cross it either: they can only regroup domains, and that is logged.
  3. The mail service enforces the boundary itself. The configuration carries an opaque organisation id per domain (org-<random> for a group; a domain that stands alone is its own dom-<domain>). The mail service checks it on every access, not only when a share is created, and ignores shares that no longer fit (a domain moved to another organisation, a mailbox deleted, a personal mailbox made shared).
  4. Two kinds of state:
    • Administered state lives in <data>/ownmail.db and is pushed in the configuration: organisations, mailbox kind (personal, shared, resource), display name, grants on shared mailboxes, distribution groups, app-password records, booking rules.
    • User data lives in the mail service (mail.db and files): filter scripts, out-of-office, calendars, events, address books, contacts, sharing of calendars and address books, per-user read state, connected AI programs. The control plane never stores it.
  5. Everything groupware runs in the mail service, like mail. It has the data and the sign-in throttle.
  6. The mail service authenticates the mailbox itself. Its account API (/account/api/), DAV (/dav) and MCP (/mcp) check the mailbox's own credentials, so a scoping mistake in the control plane cannot reach another mailbox. Changes to administered state made by the mailbox (password, app passwords, display name, delegation) are applied by the mail service at once and reported as events with the new hash, never the password. The control plane reads events, records the change in its database and in the activity log, so the next push keeps it. See Revisions.
  7. One web address for the people who read mail: the mail server name (https://mail.example.com). The account API, DAV, MCP and its sign-in answer only under that name. In OwnMail it is also the address of the administration (/admin/) and of the page for mailbox users (/); ownmail serve routes by path (cmd/ownmail/http.go, internal/webui).

Mailbox accounts

G1. Display name per mailbox: set by an administrator and changeable by the person.

Account API (internal/mail/account, /account/api/ on the mail server name). A mailbox signs in with its address and main password and can change its password, display name and "only app passwords", create and revoke app passwords, download the Apple setup, see the settings for mail programs, and reach everything below (filters, delegation, calendars, sharing, connected programs). The routes are listed in Usage. The page for mailbox users at / (web/src/account/) sits on top of it and talks only to this API, never to the administration's /api/.

  • Sign-in: only the main password, also when "only app passwords" is on; anything of the form of an app password fails after the same work as a wrong password. Throttle per (network, address) and per network, IPv4 per address, IPv6 per /48, fail closed when the tables are full; its own password-check slot, so a flood there cannot slow IMAP, nor the other way round. The client address comes from X-Forwarded-For, which ownmail serve sets to exactly the address the trusted proxies (-trusted-proxies) report.
  • Sessions in mail.db, kept by sesam in its auth_* tables: only the SHA-256 of a 256-bit token is stored; the mailbox is the sesam user named by its storage id, and account_signins holds the address and a fingerprint of the password hash the sessions were opened with; at most 20 per mailbox. The password itself is checked by the mail service against the configuration, as for mail programs. The cookie __Host-ownmail_mailbox is Secure, HttpOnly, SameSite=Strict. Every request checks the session against the current configuration, so a password reset, a change on another device, a deleted mailbox or one made shared ends it at once. Idle 30 minutes, at most 12 hours.
  • CSRF: changing requests need X-Ownmail-Request: 1; a Sec-Fetch-Site other than same-origin, or an Origin that is not https:// + the request's host, is refused; requests for another host than the mail server name answer 404. 30 changes per session in 15 minutes; bodies at most 16 KiB (256 KiB for filters).
  • There is no password reset by e-mail; an administrator resets it.

App passwords:

  • Generated tokens op_ + 16 base32 characters of id + _ + 32 of secret (160 bits), shown once, one per device.
  • Stored as HMAC-SHA-256 under one server key (made once, sealed with <data>/secret.key, pushed in the configuration) of the secret together with the mailbox's storage id and the app password's id, so a MAC is worth nothing for another mailbox or id. Checking one costs a single fast hash looked up by id, and the timing reveals nothing about how many exist. A main password of that form is refused.
  • Valid for IMAP, SMTP, DAV, ManageSieve and MCP, never for the account API's sign-in. A revoked app password stops working at once, including in open IMAP and DAV sessions.
  • The last use (time and network, at most once an hour) is reported as an event; the account API shows the last 30 days.
  • Only allow mail programs with app passwords: the main password then works only for the account API.
  • At most 50 per mailbox. The activity log records creation and revocation with the device name, never the token.

Organisations are managed in the web interface and the API (/api/mail/organisations, PUT /api/mail/domains/{domain}/organisation).

Revisions

Changes a mailbox makes itself through the account API must win over an older pushed configuration until the control plane has seen them:

  • The mail service gives each such change a revision (max(pushed, own) + 1) and keeps it as an overlay per field (password, display name, the switch, app passwords added or revoked, delegation) in mail.db, written together with its event.
  • The control plane applies an event only if its revision is higher than the mailbox's, stores that revision and pushes it; the mail service drops every part of the overlay the pushed revision reaches.
  • When an administrator changes the same field (resets the password, say), the push also says when, and the mail service drops a part of the overlay that is not newer, even before the control plane saw the event. Before saving such a change, the control plane reads the pending events, so the push that follows includes the mailbox's own changes. An administrator renaming a mailbox never undoes the mailbox's own password change.
  • Events that cannot be recorded (the database failed) wait, in order per mailbox, and are tried again first on every round; the mail service keeps the change meanwhile.

Filters and out-of-office

G2. Where Sieve runs: at every local delivery, on port 25 and in submission (mail between colleagues, so out-of-office also answers internal mail), once per recipient mailbox, after the spam checks. envelope :to is the address that reached the mailbox. Junk: keep and the implicit keep go to Junk; an explicit fileinto moves it. A failed run, a missing folder or a redirect that may not happen keeps the message: filters never lose mail.

Own interpreter (internal/mail/sieve): after reading foxcpp/go-sieve, which lacks vacation, date, include, duplicate, spamtest, mailbox and runtime limits, writing exactly the needed subset was less work and risk. Extensions: fileinto, mailbox, envelope, imap4flags, body, copy, variables, relational, date/currentdate, vacation, vacation-seconds, include (:global refused), duplicate, spamtest/spamtestplus (mapped to the content score), regex (at most 1 KiB, Go's linear-time RE2). reject and ereject are not offered: one reply to DATA covers every recipient, so a per-recipient reject would become a bounce after the fact (backscatter). Limits per run: 50 000 steps, 2 seconds, 100 actions, one vacation. Scripts: at most 10 per mailbox, 64 KiB each, checked when saved; the parser and runner are fuzzed.

Out-of-office follows RFC 5230 and RFC 3834. It replies only when one of the mailbox's own addresses is in To or Cc; there is no Auto-Submitted other than no, no Precedence: bulk/list/junk and no List-* header; the sender is not empty, MAILER-DAEMON, owner-*, *-request, LISTSERV or our own address; and the message is not Junk. Stricter than the RFCs: only to confirmed senders (SPF pass for the sender's domain, or a passing DKIM signature of the same organisational domain; mail between mailboxes counts as confirmed), so forged senders get no backscatter. Once per (sender, handle) and period (1 to 90 days, default 7), with the null sender, Auto-Submitted: auto-replied, In-Reply-To, References, DKIM-signed, limited by the mailbox's and the domain's limits on counters of their own (apart from the mail the mailbox sends itself). Reaching a limit skips the reply silently and does not count as a limit hit, so outside mail can neither keep a mailbox from sending nor get it blocked.

Redirect is forwarding with SRS and the domain's limit, plus the mailbox's own limits, counted like out-of-office replies; never for Junk or DMARC failures; only while the mailbox may forward (an administrator setting, on by default); at most 5 addresses per message; never to the mailbox's own addresses. Loops: the copy gets Delivered-To and X-Ownmail-Loop (an opaque mark, not the address; marks written by earlier versions count too); a message that already carries this mailbox's mark, 5 marks, more than 30 Received or a nesting of 5 is not redirected. Two steps: every recipient mailbox stores first; forwards outside, replies and duplicate ids follow only once the message is accepted.

Simple settings (internal/mail/rules): out-of-office, forwarding and filter rules generate the script ownmail, which carries its settings as JSON on one comment line; it can be edited as long as it is exactly what its settings generate. Any other active script makes the simple settings read-only and offers to replace it; a hand-written script stays stored (inactive) when replaced.

ManageSieve (internal/mail/managesieve, -managesieve :4190): STARTTLS only; before it only CAPABILITY, STARTTLS, NOOP and LOGOUT. AUTHENTICATE PLAIN through the IMAP sign-in (app passwords, "only app passwords", throttle), re-checked before every command. PUTSCRIPT and CHECKSCRIPT answer NO "line N: …". Limits: lines 8 KiB, scripts 64 KiB, 10 scripts, 3 failed sign-ins, 20 commands before sign-in.

Administrators set or clear out-of-office and forwarding for a mailbox (for staff who left; PUT /api/mail/mailboxes/{id}/out-of-office and …/forwarding), recorded in the activity log, and the person sees who set it. They see whether a reply is on and its dates; the text and forwarding address only when an administrator set them.

The Manage right (with G3): the account API's filter routes take ?mailbox=<address> for a mailbox the signed-in one may manage, checked on every request; ManageSieve takes it as the authorisation identity, checked after the password and before every command. A \Seen set by a filter is dropped when storing into a shared mailbox (the read state there is per reader). An out-of-office reply of a shared mailbox comes from the shared address, never from the person who set it.

Shared mailboxes, delegation, distribution groups

G3. A shared mailbox has no password and cannot sign in. It receives mail and has a quota, folders and its own filters. Administrators grant access to personal mailboxes of the same organisation:

Right Effect
Read see folders and messages; own read state
Write flags, move, delete, create folders (includes Read)
Manage filters and out-of-office of the mailbox
Send as From = the shared address (and its forwarding addresses)
Send on behalf From = shared address, Sender = own address

A personal mailbox can also delegate itself (an assistant reads the boss's mail) through the account API (PUT /account/api/delegations), with the same rights. Administrators see those grants and may remove them, but not give them. At most 100 grants per mailbox.

Converting: to shared drops the password, app passwords and "only app passwords", ends IMAP, SMTP and account sessions and removes the access it had to other mailboxes. To personal needs a new password and turns keep-sent-copy off; the grants others have stay and then count as the person's own sharing.

IMAP (internal/mail/imapd/shared.go):

  • Sessions are multi-mailbox. Shared folders appear as Shared/<address>/… in a plain LIST and are always subscribed, because iOS and Outlook ignore NAMESPACE; NAMESPACE announces Shared/ for those that use it. They never carry \Sent, \Drafts, \Trash or \Junk, so no program adopts them as the person's own. Own folder names Shared/<something with @>/… are reserved.
  • The ACL extension is not announced (go-imap v2's server cannot be extended with it without a fork). Read-only grants select folders READ-ONLY, forbidden actions answer NO [NOPERM].
  • Per-user \Seen in shared mailboxes: each reader has their own read state; other flags are shared. In a delegated personal mailbox everyone shares the owner's read state (like Exchange delegates).
  • COPY/MOVE across mailboxes: copying out needs Read, copying or moving in needs Write on the destination; quota is charged to the destination.
  • Removing a grant while one of its folders is selected ends that connection; removing Write makes the selected folder read-only.

Sending (internal/mail/submission): send as allows the shared address and forwarding addresses that deliver to it alone. On behalf allows From = the shared address only with a Sender holding the signed-in mailbox's own address; MAIL FROM may be the shared address, so bounces reach the team. DKIM signs with the From domain. Limits count for the shared mailbox and for the sender; a blocked mailbox among them cannot be sent for. Keep a copy stores the message in the shared mailbox's Sent folder, marked read for the sender, and skips a later copy with the same Message-ID.

Distribution groups: forwarding addresses with a sender policy (anyone, the organisation, or members), checked at submission against the signed-in mailbox and on port 25 against the envelope sender, which then needs SPF or DKIM to pass for exactly its domain. Refusal: 550 5.7.1 This address accepts mail only from certain senders. Only the addressed address's policy is checked, not that of groups it expands to. Hide from the address book leaves it out of the directory.

The configuration validates everything again: the same organisation only, no grant to itself, no grant held by a shared mailbox, no policy on the catch-all. A grant that no longer fits is kept, shown as not in effect and left out of the push; it works again once the domains are grouped again.

Calendars, contacts, directory

G4a. Protocols: CalDAV (RFC 4791) and CardDAV (RFC 6352) over WebDAV, plus sync (RFC 6578) at https://<mail server name>/dav/.

Discovery: Apple and DAVx5 look at the address's domain, whose website is often hosted elsewhere, so each domain's records list SRV _caldavs._tcp/_carddavs._tcp 0 1 443 <mail host>. and TXT path=/dav/ (recommended). /.well-known/caldav and /.well-known/carddav answer with 301 to /dav/. The Apple setup profile has CalDAV and CardDAV payloads.

Tree: /dav/principals/<address>/, /dav/calendars/<address>/<calendar>/<object>, /dav/addressbooks/<address>/<book>/<object>, the directory at /dav/addressbooks/<address>/directory/.

  • Sign-in: HTTP Basic on every request through the same check as mail programs (main password unless "only app passwords", or an app password; cached). Requests for another host than the mail server name answer 404. 3000 requests per mailbox in 5 minutes, then 429.
  • Own handler: emersion/go-webdav was read and not used: its servers own the request handling (fixed interfaces, no sync-collection in the server, no privilege sets, no quota, no PROPPATCH). The handler and the XML (encoding/xml with our own limits) are ours; emersion/go-ical (with teambition/rrule-go) and emersion/go-vcard parse.
  • Storage: files under dav/<storage_id>/<collection id>/ in the mail data with the same durability as messages, indexed in mail.db. ETags, ctags and sync tokens are derived from a DAV epoch, the collection and a sequence number; a restore starts a new epoch, so every client resyncs. Deletion records are kept 90 days (at most 10 000 per collection); an older token gets 403 valid-sync-token.
  • Quota: DAV data counts towards the mailbox quota; a PUT that would pass it answers 507.
  • Default collections ("Calendar", "Contacts") are created on first use.
  • Objects: one VEVENT or VTODO (with its overrides) per calendar resource, or one vCard; stored byte for byte. An object with a second event or task is refused before its repetitions are worked out. Limits: 1 MiB per object, 100 collections per mailbox, 100 000 objects per collection, XML bodies 1 MiB / depth 32 / 20 000 elements, document type declarations refused.
  • Time ranges: the index keeps the span of all occurrences; recurrence is expanded up to 20 000 occurrences and 20 years. Time zones resolve from IANA names, X-LIC-LOCATION, common Windows names, else a fixed offset; floating times are widened by 14 hours so no reader's zone misses them.
  • Reports: calendar-query, calendar-multiget, addressbook-query, addressbook-multiget, sync-collection, principal-property-search. COPY, MOVE and LOCK are not offered.
  • Directory: a read-only address book per organisation in every mailbox's home, vCards of the organisation's mailboxes, rooms and forwarding addresses (not the catch-all), except those hidden.
  • Import/export: .ics and .vcf per collection through the account API (10 MB, entries with a UID that exists replace it); the mailbox export zip holds calendars/ and contacts/.

Outlook has no native CalDAV; the free CalDav Synchronizer add-on is the documented route.

Sharing calendars and address books

G4b. A person shares a collection with personal mailboxes of the same organisation, read or read-write, through the account API. Shares are user data (dav_shares in mail.db): nothing is pushed, nothing is in ownmail.db. At most 100 shares per collection and 200 received per mailbox.

  • Shared collections appear inside the receiver's home as shared~<share id>, so every program shows them without special support. Every href uses the receiver's URL; every write goes to the owner's storage, so data, quota, ETags and sync tokens are the owner's.
  • current-user-privilege-set tells the truth: read shares report read, read-free-busy; read-write adds write, bind, unbind; never write-acl. The owner's principal and quota are not shown.
  • The receiver's name and colour for it are their own (PROPPATCH changes only those). The receiver's DELETE removes only the share.
  • Like grants, the organisation is checked on every request; a share that no longer fits is kept and shown to the owner as not in effect.
  • Team collections: shared mailboxes and rooms get a calendar and an address book too, reached through the mailbox's grants (Read gives read, Write gives read-write) as shared~<storage id>~<name>, named " ()".
  • Not doing: Apple's and CalendarServer's sharing invitations, calendar-proxy delegation, sharing outside the organisation, public links.

Scheduling

Free/busy and invitations to and from outside

G5a.

  • Scheduling is announced: the DAV header has calendar-auto-schedule and principals have schedule-inbox-URL and schedule-outbox-URL (/dav/calendars/<address>/~inbox/, ~outbox/), so programs leave sending invitations and replies to the server (RFC 6638). Programs that still send themselves set SCHEDULE-AGENT=CLIENT, which the server honours. Schedule-Tag and If-Schedule-Tag-Match come with it; when scheduling changes a stored object, the PUT answers without ETag and the program fetches it again.
  • Calendar user addresses: the mailbox's address and the forwarding addresses that lead to it alone, never a group such as all@.
  • Outgoing invitations (iMIP, RFC 6047): when a PUT or DELETE changes an event the mailbox organises, the server compares it with the stored version (by UID across all the organiser's calendars, so moving an event sends nothing) and sends REQUEST to new attendees, and to all when date, time, recurrence, location, title or status changed; CANCEL to removed attendees, and to all when the event is deleted or cancelled. One message per change, from the organiser's address with display name, DKIM-signed, through the sending pipeline, counted against the sending limits. The object is stored first, then the messages are sent; a refused send marks the attendees SCHEDULE-STATUS:5.1. Deleting a whole collection or importing never sends.
  • Writes by others: a holder of a read-write share who changes the owner's event sends nothing; attendees they add are marked as not invited (5.3) until the owner invites them on purpose. In a team calendar, a holder with send as or on behalf schedules as the shared mailbox.
  • Attendee side: a change of the attendee's own PARTSTAT on an event organised outside sends an iMIP REPLY; deleting it sends DECLINED unless it was cancelled, or Schedule-Reply: F was sent.
  • Incoming replies update the organiser's event only when the UID matches an event the mailbox organises, the replying attendee is listed, the From address equals that attendee, and SPF or DKIM passed for exactly the From domain (or it came from a mailbox here). Older replies are ignored. Events from outside are never added automatically: invitations stay mails, which programs offer to accept.
  • Free/busy within the organisation: through the outbox (POST of a VFREEBUSY request) and free-busy-query. Only busy times, never titles; transparent and cancelled events and declined invitations are free, unanswered and tentative ones BUSY-TENTATIVE. A person can turn it off (PUT /account/api/free-busy). Outside the organisation: 3.7;Invalid calendar user. At most one year per request and 60 questions per mailbox in 5 minutes.
  • Finding attendees: principal-property-search within the organisation (name and addresses, at most 50 results).
  • Limits: at most 100 attendees per event, 5 sending changes per event per minute; beyond that the change is stored and its invitations are skipped.

Scheduling between mailboxes

G5b. Inside the organisation, mail is replaced: the server keeps each attendee's copy in step with the organiser's event, and the attendee's answer updates the organiser's copy directly. Other organisations on this server and addresses outside still get iMIP mail.

  • Jobs: all internal work goes through a durable job table (sched_jobs in mail.db) written in the same transaction as the change that causes it, run in order per event by a worker (woken after every commit, polling every 10 seconds). Transient errors back off (1, 5, 15, 60 minutes, at most 10 attempts). At most 500 unfinished jobs per mailbox.
  • Where a copy goes: for a personal mailbox, the calendar chosen for invitations (schedule-default-calendar-URL), else "Calendar", else the first calendar that takes the component; for a shared mailbox, its team calendar; for a room, its calendar after the booking check.
  • A copy holds only the components that list the attendee, without the organiser's alarms, scheduling parameters, inline attachments or the server's own X-OWNMAIL-* values; at most 256 KiB. A copy is updated only when its organiser is the same mailbox, so the attendee's own data is never overwritten. The attendee's alarms, categories, TRANSP, declined dates and own answer are kept on update; the organiser's answer wins only on a reschedule.
  • Silent and announced changes: every change of the organiser's data updates the copies; only new invitations, reschedules and cancellations are announced, with an item in the attendee's scheduling inbox (kept 30 days, at most 200, counted against the quota) and a short notification mail (no calendar part, so mail programs do not write second copies). A person can turn the mail off (PUT /account/api/invitation-mail). At most 10 mails an hour and 50 a day per organiser and person, 500 an hour per organiser.
  • Answers: an attendee's change of their own PARTSTAT, for the whole event or one date, updates the organiser's copy (SCHEDULE-STATUS:2.0) and, coalesced and rarely (60 seconds, at most once per event per 15 minutes, not for more than 20 internal attendees), the other attendees' copies. An answer for one date of a series makes the server create an override in the organiser's event (at most 100 per event), which a stale organiser PUT does not delete. One answer mail is looked at for at most 100 such dates; the rest of it is not applied.
  • Cancellation keeps the attendees' copies, marked CANCELLED. A copy the attendee deleted comes back only on a new invitation or a reschedule, never while they declined.
  • Limits: a change that delivers internally counts as one message against the organiser's and the acting person's hourly and daily limits, not the domain's; at most 50 new copies per organiser and person a day.
  • Deviations from RFC 6638: attendee changes beyond their answer are accepted and ignored (the organiser's next update overwrites them); COUNTER, DECLINECOUNTER and REFRESH are not offered; several copies of a UID from the same organiser are allowed and kept in step.

Rooms and equipment

G5b-2. A mailbox of kind resource: no password, a quota, grants like a shared mailbox, and booking rules (PUT /api/mail/mailboxes/{id}/booking):

Field Meaning Default
type room or equipment room
auto accept or manual (wait for approval) accept
bookers personal or shared mailboxes of the organisation, at most 100; empty = everyone of the organisation empty
window_days 1–730 365
max_minutes longest date 480
max_booked_minutes per organiser, inside the window 2400
capacity for information —
  • Booking runs inline (at most 2 seconds) under a lock per resource, so the organiser's program sees the answer on its next fetch. The request is expanded and clipped to the window; it is declined as a whole when any date collides with another booking or a blocked time, more than 500 dates fall in the window, a date is too long, the first date lies beyond the window or all in the past, or the organiser's booked minutes would pass the limit. Rules that are never expanded (more often than hourly), dates with their own length and floating times are declined. A series that runs past the window is accepted with conflicts checked inside the window only. The decline names up to three colliding dates. Not allowed to book: 3.8, nothing written. An update is checked again when its times, its status or a time zone it uses changes in any way, also only in the order of the zone's definitions.
  • The room's copy keeps times, recurrence, title, location, organiser and attendees; no description, attachments, links or alarms.
  • Holders: Read holders see the calendar; Write holders accept, decline and cancel (never move: organiser data in their PUT is replaced by the stored version), get a mail per waiting request (at most one an hour per event), and block times with events without organiser. Accepting a request that now collides is refused with 409.
  • Visibility: busy times of rooms answer the whole organisation; details only to holders. Invitations from outside the organisation are delivered as mail and never answered (no backscatter).
  • calendar-user-type is ROOM or RESOURCE; principal search can filter on it. Apple's calendarserver-principal-search (probably used by its room picker) is not built.

Client test matrix

What calendar programs are expected to do. Not tested on real devices yet; the protocol shapes are covered by scripted tests.

Behaviour Apple Calendar Thunderbird 115+ DAVx5 Outlook + CalDav Synchronizer
Leaves invitations to the server yes likely never sends iTIP sends its own meeting requests
Attendee search principal search directory address book contacts only address book
Free/busy while inviting outbox outbox none none
Accepting PUT with If-Schedule-Tag-Match PUT with If-Match PUT, may raise SEQUENCE via sync
Conflict after another attendee answers none (Schedule-Tag) may ask "changed on the server" re-syncs unknown
Rooms room picker probably needs a search not built; by address works by address by address by address

AI programs (MCP)

G7. Every mailbox can be used from AI programs through the Model Context Protocol at https://<mail server name>/mcp (internal/mail/mcpd; streamable HTTP, stateless, JSON responses). The operations behind the tools live in internal/mail/client, which knows nothing of MCP, so a later webmail can use the same package.

Sign-in, two ways (the main password is never accepted):

  1. App passwords as bearer tokens for programs set up by hand: Authorization: Bearer op_…. The mailbox is found by the app password's id and checked through the same sign-in as IMAP (throttle, cache, revocation). An app password has every right. Guessed tokens with unknown ids count per network: 5 per 15 minutes, then 429.
  2. OAuth 2.1 for programs that connect by address, following the MCP authorisation spec of 2025-11-25 (internal/mail/oauth, an own small server rather than a general plugin, because grants must be bound to the mailbox's password hash and carry rights instead of scopes):
    • Metadata at /.well-known/oauth-protected-resource/mcp and /.well-known/oauth-authorization-server (issuer https://<mail server name>); /oauth/authorize, /oauth/token, /oauth/register, /oauth/revoke.
    • Client ID Metadata Documents first (fetched as untrusted input: https only, public addresses only, 5 KB, 5 seconds, no redirects, client_id must equal the address), dynamic registration as the fallback (at most 1000 programs; when full, programs without a connection to any mailbox make room, never-authorised ones first; unused ones pruned after 30 days). An authorisation request in progress keeps its program, but only for the newest requests, at most 2 per network and 250 in all, since requests need no sign-in. Authorisation code with PKCE S256 only; redirect addresses exactly as registered (https, or loopback with any port).
    • The authorisation request waits (10 minutes) and the browser is sent to /?connect=<request>, where the person signs in with address and main password and chooses the rights (account API GET/POST /account/api/connect/{request}; the page is web/src/account/ConnectScreen.tsx).
    • Access tokens last an hour (opa_…), refresh tokens 30 days and rotate (a reused one is accepted once more within 30 seconds, which revokes what its first use issued; any other reuse ends the grant). Stored only as SHA-256. Grants are bound to the storage id and a fingerprint of the password hash: a password change, a conversion to shared or a deleted mailbox ends every grant. At most 20 per mailbox. A new connection puts a notice into the mailbox's inbox.

Rights: read (always), organise (flags, move, delete, folders, drafts, turning out-of-office off), send within the organisation, send to anyone (also turning out-of-office on: the reply answers every sender, also outside the organisation). A program sees only its tools (7 read, 17 with organise, 20 with sending) and every call checks again. "Outside" is a domain not on this server, another organisation, an unknown local address, or a forwarding address that reaches outside.

Switches: per mailbox and per domain, "may be used by connected programs" (on by default), set by administrators. Off: /mcp answers 403, connecting is refused, existing grants stay but do not work, and a shared mailbox turned off is invisible to everyone's programs.

Tools (ids are opaque <mailbox>/<folder id>/<uidvalidity>/<uid>, so a stale id answers "not found" instead of hitting another message):

Tool Right What it does
list_mailboxes read the own mailbox and the shared and delegated ones, with rights and the addresses it may send as
list_folders read folders with role, total and unread
search_messages read from, to, subject, text, since, before, unread, flagged, has attachment; newest first, 50 per page with a cursor; one call reads at most 256 MB and runs at most 10 s
get_message read header fields, text (HTML turned into text, 200 KB), attachment list; mark_read
get_attachment read one attachment, at most 10 MB
get_thread read the conversation in the mailbox, at most 100 messages
get_out_of_office read the simple settings
set_flags organise read, flagged, answered, keywords
move_messages, copy_messages organise within a mailbox or across, with IMAP's rights and quota
delete_messages organise to Trash; for good with permanent and confirm (or when already in Trash)
create_folder, rename_folder, delete_folder organise delete_folder needs confirm
save_draft, delete_draft organise a draft in Drafts, replaced by id
set_out_of_office organise own mailbox or one it manages; turning it on also needs send to anyone; never replaces hand-written filters
send_message send to, cc, bcc, subject, text, optional HTML, attachments, from, draft_id
reply_message, forward_message send build subject, recipients, references and the quoted or attached original, then send

Sending goes through the same pipeline as submission (internal/mail/submission/pipeline.go): send as and on behalf, recipient and size limits, the mailbox's and domain's limits and blocks, DKIM, the queue, local delivery with filters, keep-sent-copy, and a copy in the sender's Sent folder. The server builds the message; no raw header fields. On top, at most 100 recipients outside the organisation per mailbox in a rolling 24 hours, because a program misled by a mail is a way to leak mail content.

Mail is untrusted input: the server's instructions and every tool that returns mail say it is data, never instructions. The text the model reads from search_messages, get_message and get_thread is the whole answer inside one <mail-content-<random>> fence the message cannot guess; text attachments are fenced too. The protection is in the rights: a program that may only read or organise cannot send; one without "send to anyone" cannot send out of the organisation.

Limits: 600 requests per app password or grant and 1200 per mailbox in 5 minutes, 4 at once per mailbox (429 with Retry-After); request bodies up to 32 MB on /mcp (16 MB on the other paths of the mail service's web handler); no JSON-RPC batches; 1000 ids per call.

Activity: connections and disconnections are events (mail.mailbox.mcp-granted, mail.mailbox.mcp-revoked, with the program's name and rights, never a token). Mail read or sent through MCP is not logged beyond what mail itself logs.

Not in G7: calendar and contact tools, filters beyond the simple settings.

Webmail, web calendar and contacts

G6, not built. It would run under the mail server name for the mailbox's own session and use the account API and internal/mail/client. A page for mailbox owners (account settings, sharing, the AI consent step) belongs with it.

Libraries

  • Sieve: our own interpreter (internal/mail/sieve); foxcpp/go-sieve lacks vacation, date, include, duplicate, spamtest, mailbox and runtime limits.
  • DAV: our own handler and XML on encoding/xml; emersion/go-webdav was not a fit.
  • iCalendar/vCard: emersion/go-ical (with teambition/rrule-go) and emersion/go-vcard for parsing.
  • OAuth for /mcp: our own small authorisation server (internal/mail/oauth).

Permissions

Administrator Mailbox (its own credentials)
Group domains into organisations yes (logged) no
Make a mailbox shared, personal or a room yes no
Grant access to a shared mailbox or room, distribution groups, booking rules yes, same organisation only no
Delegate a personal mailbox see and remove yes, same organisation
Password, display name, app passwords set or reset yes
Filters see whether hand-written yes (and for mailboxes it manages)
Out-of-office, forwarding set or clear (logged) yes (and for mailboxes it manages)
Share own calendars and address books no yes, same organisation
Read calendars, contacts, filters of others no own and those shared with it
Allow a mailbox to be used from AI programs yes no
Connect and remove AI programs no yes

Administrators can reset a password and thereby read everything; Usage says so.

Known limits

  • iOS has no IMAP push for servers other than Apple's and Exchange; it fetches every 15 minutes. DAV has no push either.
  • Signatures stay in the mail programs.
  • Outlook: IMAP and CalDav Synchronizer; shared folders show poorly over IMAP. The new Outlook syncs IMAP through Microsoft's cloud, so many people share a few Microsoft addresses, which the per-network throttle counts together.

Not doing

  • ActiveSync (EAS), EWS, MAPI/HTTP: huge, partly undocumented protocols, and ActiveSync needs a patent licence from Microsoft.
  • Public folders in Exchange's sense: shared mailboxes cover the use.
  • Chat, video, documents: out of scope for a mail server.

Home

Running OwnMail

Using OwnMail

How it is built

Taking part

Clone this wiki locally