Actions
97 actions, callable from the panel, the command palette and the API as
POST /api/v1/a/<id>. Internal actions used between modules are not listed.
| Action | What it does | Risk | Preview |
|---|---|---|---|
webmail.session.open | Sign in to a mailbox | medium | |
webmail.session.sso | Open webmail for a mailbox without its password | medium | |
webmail.session.close | Sign out of a mailbox | low | |
webmail.session.list | List open sessions (read) | low | No dry run |
webmail.session.watch | Choose the folder that sends live updates (read) | low | No dry run |
webmail.folder.list | List folders (read) | low | No dry run |
webmail.folder.create | Create a folder | low | |
webmail.folder.rename | Rename a folder | low | |
webmail.folder.delete | Delete a folder | medium | |
webmail.folder.empty | Empty Trash or Junk | high | |
webmail.folder.subscribe | Show or hide a folder | low | |
webmail.message.list | List messages (read) | low | No dry run |
webmail.thread.list | List conversations (read) | low | No dry run |
webmail.message.search | Search messages (read) | low | No dry run |
webmail.message.get | Read a message (read) | low | No dry run |
webmail.message.alert | Describe a new message for a notification (read) | low | No dry run |
webmail.message.source | View a message's source (read) | low | No dry run |
webmail.attachment.get | Download an attachment (read) | low | No dry run |
webmail.message.flags | Change message flags | low | No dry run |
webmail.message.move | Move or copy messages | low | |
webmail.message.delete | Delete messages | medium | |
webmail.message.archive | Archive messages | low | |
webmail.message.spam | Report spam or not spam | low | |
webmail.message.reply_template | Prepare a reply or forward (read) | low | No dry run |
webmail.draft.save | Save a draft | low | No dry run |
webmail.message.send | Send a message | medium | No dry run |
webmail.send.cancel | Undo a send | low | No dry run |
webmail.send.schedule | Schedule a message | medium | |
webmail.scheduled.list | List scheduled messages (read) | low | No dry run |
webmail.scheduled.edit | Edit a scheduled message | low | |
webmail.scheduled.cancel | Cancel a scheduled message | low | |
webmail.message.snooze | Snooze messages | low | |
webmail.snooze.list | List snoozed messages (read) | low | No dry run |
webmail.snooze.cancel | Unsnooze a message | low | |
webmail.upload.chunk | Upload an attachment chunk | low | No dry run |
webmail.upload.discard | Discard an upload | low | No dry run |
webmail.rules.get | Read mail rules (read) | low | No dry run |
webmail.rules.validate | Check mail rules (read) | low | No dry run |
webmail.rules.set | Save mail rules | medium | |
webmail.vacation.get | Read the out-of-office reply (read) | low | No dry run |
webmail.vacation.set | Set the out-of-office reply | medium | |
webmail.identity.list | List identities (read) | low | No dry run |
webmail.identity.set | Save an identity | low | |
webmail.identity.delete | Delete an identity | low | |
webmail.settings.get | Read webmail settings (read) | low | No dry run |
webmail.settings.set | Save webmail settings | low | |
webmail.sender.trust | Always load images from a sender | low | |
webmail.sender.pictures | Show senders' pictures (read) | low | No dry run |
webmail.contacts.list | List contacts (read) | low | No dry run |
webmail.contacts.save | Save a contact | low | |
webmail.contacts.delete | Delete a contact | medium | |
webmail.contacts.import | Import contacts from a vCard file | medium | |
webmail.contacts.export | Export contacts as a vCard file (read) | low | No dry run |
webmail.contacts.group | Add contacts to a group or take them out | low | |
webmail.calendar.list | List calendars (read) | low | No dry run |
webmail.calendar.save | Create or change a calendar | low | |
webmail.calendar.delete | Delete a calendar | high | |
webmail.calendar.events | List events in a window (read) | low | No dry run |
webmail.calendar.event.get | Read one event (read) | low | No dry run |
webmail.calendar.event.save | Save an event | low | |
webmail.calendar.event.delete | Delete an event | medium | |
webmail.calendar.import | Import events from an .ics file | medium | |
webmail.calendar.export | Export a calendar as an .ics file (read) | low | No dry run |
webmail.calendar.invite.read | Read an invitation in a message (read) | low | No dry run |
webmail.calendar.invite.respond | Answer an invitation | medium | |
webmail.calendar.invite.apply | Apply an update or cancellation | medium | |
webmail.connect.link | Make a link to connect a phone | high | |
webmail.connect.phones | Phones connected to this mailbox (read) | low | No dry run |
webmail.connect.revoke | Disconnect a phone | medium | |
webmail.session.handoff | Open a mailbox in the webmail app | medium | |
webmail.websession.list | List the devices signed in to this mailbox (read) | low | No dry run |
webmail.websession.revoke | Sign out another device | medium | |
webmail.host.list | List webmail addresses (read) | low | No dry run |
webmail.host.ensure | Set up webmail.<domain> | medium | |
webmail.host.remove | Stop serving webmail.<domain> | medium | |
webmail.forward.get | Read the forwarding of a mailbox (read) | low | No dry run |
webmail.forward.set | Forward this mailbox's mail | medium | |
webmail.footer.get | Read a domain's mail footer (read) | low | No dry run |
webmail.footer.set | Set a domain's mail footer | low | |
webmail.notify.get | Read the new-mail notification choice of a mailbox (read) | low | No dry run |
webmail.notify.set | Change the new-mail notification choice of a mailbox | low | |
webmail.spam.prefs.get | Read the spam settings of a mailbox (read) | low | No dry run |
webmail.spam.prefs.set | Change the spam settings of a mailbox | low | |
webmail.quarantine.list | List held mail (read) | low | No dry run |
webmail.quarantine.release | Release held mail | low | |
webmail.quarantine.delete | Delete held mail | medium | |
webmail.template.list | List saved responses (read) | low | No dry run |
webmail.template.save | Save a response | low | |
webmail.template.delete | Delete a saved response | low | |
webmail.message.receipt | Answer a read receipt request | low | |
webmail.account.list | List other mail accounts (read) | low | No dry run |
webmail.account.discover | Find the settings of a mail account (read) | low | No dry run |
webmail.account.test | Test a mail account (read) | low | No dry run |
webmail.account.add | Add another mail account | medium | |
webmail.account.update | Change a mail account | medium | |
webmail.account.check | Try a mail account again | low | No dry run |
webmail.account.remove | Remove a mail account | medium |
Permissions and limits
Permissions
webmail.session.useSign in to a mailbox in webmailwebmail.session.ssoOpen webmail for a mailbox without its passwordwebmail.mail.readRead and search mailwebmail.mail.writeFlag, move, archive and delete mailwebmail.mail.sendWrite and send mailwebmail.folder.manageCreate, rename and delete folderswebmail.rules.manageManage mail rules and the out-of-office replywebmail.identity.manageManage sending identities and signatureswebmail.contacts.useUse the contacts of a mailboxwebmail.calendar.useUse the calendars of a mailboxwebmail.settings.manageManage webmail preferenceswebmail.accounts.manageAdd other mail accounts (Gmail, a former host) to webmailwebmail.hosts.manageSet up webmail addresses (webmail.<domain>) and domain footers
Plan limits
webmail.identitiesSending identities per account
Engineering notes
Generated from modules/webmail/docs.md at build 38156245. These are the notes the engineers keep
next to the code: precise, technical, and honest about what is not done yet.
The module is a plugin that sits between the browser (which cannot speak IMAP) and the mailbox's Dovecot/Postfix
(ADR 0012 §1). It stores no mail and no mailbox password: one live IMAP connection per signed-in mailbox lives in
the plugin process; the password is kept in memory for the life of the session (needed to reconnect and to
authenticate SMTP/ManageSieve) and zeroed on close. Libraries: emersion go-imap v2, go-smtp, go-message, go-sasl (MIT,
in THIRD_PARTY_NOTICES.md); the HTML sanitiser is our own on golang.org/x/net/html.
Layout: gw/ (gateway, no platform types, unit-tested against in-process IMAP/SMTP servers), sanitize/ (HTML mail
sanitiser), cp/ (thin action handlers, DB for identities/preferences), schemas/, migrations/.
The webmail app (w12 G2, ADR 0035)
The mail client is its own page, not a panel screen. ui/app/ (entry main.tsx, index.html with <base href="/">)
builds with vite.app.config.ts into ui/dist/app/, React and @rc/ui bundled; the daemon serves it at
webmail.<domain> and at /mailbox/ on the panel's hostnames (internal/webui/app.go rewrites <base href>).
ui/dist/index.js (the panel bundle) is now only the panel's Webmail page, src/launcher.tsx: mailboxes with
"Open" (webmail.session.handoff: a tab is opened on the click, then sent to the #claim= link; your own mailbox opened
this way stays signed in on that device for 30 days, while staff opening somebody else's mailbox keep 30 minutes), "Sign in with a
password" (/mailbox/?address=), and the webmail addresses (webmail.host.list, "Set up" / "Check again" =
webmail.host.ensure as a job, the record under "Show details").
src/lib/transport.ts: the only HTTP client of the app,/api/webmail/a/<action>withX-RC-Webmail: 1;step_up_requiredopens the password dialog (standalone/step-up.tsx,/api/webmail/confirm) and retries.src/lib/live.tsx(rules insrc/lib/live-stream.ts): oneEventSourceon/api/webmail/eventsfor every signed-in mailbox (named events per topic, each with an id; a reconnect resumes afterLast-Event-ID). Every (re)open, and the server'src.resync, reloads the folder counts and the lists, so nothing sent while the stream was down is lost; reopened with backoff when the server refused it. The app bar's dot reads live / reconnecting, and turns to reconnecting only after 4 s down (no flash on a reopen).signed_out, orrc.endfor an ended sign-in, sends the page back to sign-in. The tab title is(<unread>) <folder> | <address>.src/standalone/:shell.tsx(session from/api/webmail/session,#claim=redeemed first, up to five mailboxes with a switcher, appearance, sign out of one or all),signin.tsx(address + password + "Stay signed in"; onwebmail.<domain>the name alone is enough; "Stay signed in" has no fixed end since 1.0.54, owner 2026-11-24 "like google": it ends after 90 days unused, at sign-out, when the device is removed or when the password changes, and each start of the app renews the cookie;lifetimeincp/public.go),brand.tsx(/api/webmail/brandmapped onto the primary tokens),router.ts(routes under the base:""mail,settings[/<pane>]).- The composer, saved responses and the signature use one small formatting editor (
components/rich-editor.tsx, helpers inlib/rich.ts): bold, italic, lists, links. A message goes out as HTML plus a plain-text twin (message.htmlandmessage.text); the signature block is markeddata-sigso choosing another identity swaps it. Settings has a Responses tab (settings/responses.tsx, actionswebmail.template.*); the composer's Responses menu inserts one. - Settings panes keep their working copy with
useDraft(settings/api.tsx), which shows the server's data on the first render. - Settings is a route and a lazy chunk:
src/settings/index.tsx, default exportSettingsPagewithSettingsPageProps(tab,onTab,onBack,seed,onSeedUsed,labels). - Not in the app: the panel assistant (its buttons were panel-only), switching contacts/calendar sync on (a sentence says the hosting provider does it in the panel).
Sessions
webmail.session.open {address, password} -> {session, folders, expires_at, ...}. Every other action takes that
session id. A session belongs to the panel principal that opened it (Actor.principal_id); nobody else can use or
close it. It expires after 30 min idle (settings session_idle_minutes) or 12 h absolute, whichever first; closing it
first delivers any message still inside its undo window. Max 10 sessions per principal. Failed sign-ins: 5 misses in
10 min lock that (principal, address) for 10 min; failures are audited. The IMAP host comes from
mail.client.config called as the caller (so mail's access rules apply), never from the request.
SSO (webmail.session.sso) checks the caller can see the mailbox (mail.mailbox.list), asks the mail module for its Dovecot
master user (mail.sso.prepare, answered to the webmail module only; the master password is made on first use and kept in
the mail module's vault) and signs in as address*rcmaster. A mailbox of another account (staff "Open") needs a fresh
step-up, the session lasts at most 30 minutes, the audit log records who opened which mailbox (webmail.session.sso.staff)
and the event webmail.sso.opened goes to the mailbox's account.
Module settings (JSON, schema schemas/settings.json)
host_override (dial this host, e.g. 127.0.0.1) + server_name (certificate name to verify), skip_tls_verify
(self-signed mail cert, lab), imap_port/imap_security, smtp_port/smtp_security, sieve_port, max_attachment_mb
(25), session_idle_minutes, session_max_hours, live_updates (IDLE, default on), sender_pictures (all, icons
or off; see "Sender pictures").
Actions (all permission-checked, schema-validated; see module.yaml)
Session: session.open/.sso/.close/.list/.watch. Folders: folder.list/.create/.rename/.delete/.empty/.subscribe.
Reading: message.list, thread.list, message.search (folder * = every folder), message.get, message.source, attachment.get,
message.reply_template, sender.pictures. Organising: message.flags/.move/.delete/.archive/.spam. Composing: draft.save,
message.send, send.cancel, upload.chunk/.discard. Rules: rules.get/.validate/.set, vacation.get/.set.
Preferences: identity.list/.set/.delete, settings.get/.set, sender.trust.
Events (owner-scoped, to the hosting account): webmail.mailbox.changed {session,address,folder,kind:exists|expunge|flags|sent|resync,exists}
(resync: the IDLE watch of that folder (re)started, at sign-in, after a park, a drop or a wait for a connection; what
arrived before it raised no event, so the page reloads the folder),
webmail.send.failed {detail}.
Reading mail safely (AC-webmail-08, -38)
Dark reading (Settings, Display, "Show emails in the dark theme"). Default "Follow the panel": on a dark panel the paper is dark too. Plain text and mail without colours use the theme colours; for mail with its own colours the client rewrites the colour values in the already-sanitised HTML (light backgrounds and dark text get their lightness inverted, hue kept; links, quotes and text are lifted to contrast 4.5 or more) before it goes into the frame. Images are never touched, no filter is used. "Always light" keeps the light paper, and each message has a "Show original colours" button. The CSP and the empty sandbox are unchanged. Stored as dark_mail (follow or light) in the mailbox preferences.
Links open when clicked (2026-11-24, owner: "when i try to open the button links none opens"). The frame's sandbox is
allow-popups allow-popups-to-escape-sandbox (still no scripts, same-origin, forms or top navigation), so a person's own
click on a link opens it in a new tab with no referrer; nothing else can open one. Junk and mail that failed the sender
checks keep the empty sandbox; their links open from the reader's link list. Mail sent from this server is verified
when the hop that handed it over came from this machine (loopback or one of its own addresses, Received) and our
filter's topmost Authentication-Results says auth=pass smtp.auth=<mailbox> of the From domain (gw localSubmission,
originatingUser); a site that hands mail over without signing in shows "Sent from this server", not verified.
sanitize.Clean parses with the HTML5 algorithm, then rebuilds a new tree from an allow-list; nothing is copied
through unchecked. Dropped with content: script, style, iframe/frame, object/embed/applet, svg/math (any foreign
namespace), template, noscript, head/title/meta/link/base, video/audio/source, select/textarea. Unwrapped (tags gone,
text kept): form, input, button, label and every unknown element. No id, class, name, on*, srcset,
formaction, background. Links: only http/https/mailto/tel survive, target=_blank rel="noopener noreferrer nofollow",
and links[] reports each target with mismatch (visible text names another host) and idn (punycode look-alike).
Inline style is reduced to presentational properties; any value with url(, expression, javascript, @import,
\, var( is dropped; position, float, z-index are not allowed. Images: cid: -> data: URI of the inline part
(raster only, <= 1 MB each, 3 MB total); data:image/svg never; http(s) images are blocked (data-rc-blocked,
counted in remote_blocked) unless load_remote or the sender is on the trusted list (sender.trust); 1x1 / hidden
images are tracking pixels: always dropped, counted in tracking_pixels. CSS url() never loads, even with opt-in.
Test corpus: ~55 XSS vectors (OWASP classics, mXSS namespace tricks, Outlook conditional comments, null bytes, entity-
encoded schemes), a tokenising oracle that re-parses the output and checks every tag/attribute/URL, and a fuzz target.
The UI must still render html in a sandboxed iframe (sandbox="", no allow-scripts/same-origin) with CSP
default-src 'none'; img-src data: https:; style-src 'unsafe-inline' — the sanitiser is layer one of two.
Attachments: names are stripped of paths/control/RTL-override characters; executable extensions are flagged
(dangerous); text/html, SVG, XML and JS attachments are served as application/octet-stream; chunked reads
(attachment.get, 1 MiB default, 4 MiB max, base64) with the decoded part cached for the session; cap
max_attachment_mb. Sender authentication shown from Authentication-Results (spf/dkim/dmarc).
Conversations and search
thread.list uses server THREAD=REFERENCES (Dovecot) and falls back to grouping the newest 1000 messages by
Message-ID/In-Reply-To/References and "Re:"-normalised subject. message.search parses operators
(from: to: cc: subject: body: has:attachment is:unread|read|starred|answered label: before: after: larger: smaller:)
into IMAP SEARCH; the remaining words are TEXT (Dovecot FTS when a plugin is configured). has:attachment is the
heuristic Content-Type: multipart/mixed. Counts in lists are exact; pages are by sequence window (newest first).
Large folders (gw/listcache.go): a conversation grouping or a search answer is built once and every page, a jump to any
offset and the 30 s refresh are cut from it; it is kept per IMAP account (shared by its sessions) while UIDVALIDITY,
UIDNEXT and the message count stay the same, plus HIGHESTMODSEQ (CONDSTORE) for the unread/flagged views, for 5 minutes
unused, at most 256 answers and 32 MiB per process. Searches ask for ESEARCH RETURN (ALL), so UIDs arrive as ranges.
Sending
SMTP submission with the mailbox's own login (587 STARTTLS; Postfix enforces login = sender, the refusal is returned as
a readable conflict with smtp_code). Addresses/subject are validated (no CR/LF/NUL injection), Bcc only in the
envelope, outgoing HTML is run through the sanitiser (scripts out, cid: kept), text part derived when missing,
multipart/mixed > alternative > related structure, attachments from chunked uploads (spooled 0600 under the module
data dir, wiped on session close; offset must match so a retry cannot duplicate bytes) or forwarded from the original.
After sending: copy to Sent, \Answered / $Forwarded on the original, draft removed. delay_seconds 0-30 = undo
window held in memory; send.cancel returns the message to Drafts; if a delayed send fails it is saved to Drafts and
webmail.send.failed is emitted. Scheduled send is below ("Scheduled send and snooze"); read-receipt handling is not done.
Across folders (w11-24)
message.search and thread.list take folder *: every selectable folder except Trash, Junk, the Snoozed holding folder
and a virtual "All mail" is searched with the server's own SEARCH (gw/allfolders.go); in:<folder|role> narrows it
(and is the only way to search Trash or Junk). The newest 300 matches of each folder are looked at; a mail that lives in
two folders (you sent it to yourself) is shown once. With threads: true the matches are grouped into conversations by
Message-ID / In-Reply-To / References / "Re:"-subject across folders, and a conversation that matches is shown whole (its
other messages are pulled in from the same folders), so a reply in Sent joins the mail it answers; every message carries
its folder. No full-text index is installed by the mail module (no fts plugin in the Dovecot config), so the free
text is a header + body scan; the result says so (full_text: false) and the UI shows "Header and body scan" with the
reason. The result flips to full_text: true the day Dovecot advertises SEARCH=FUZZY.
Scheduled send and snooze (w11-24)
Both are database queues owned by this module (migration 0002: scheduled, snoozed), worked by one loop in the plugin
process (10 s tick, cp/queue.go), so a closed browser or an expired webmail session loses nothing.
send.schedule {message, send_at, timezone}builds the finished RFC 5322 message now (same validation assend, so a bad address fails at once, attachments are inside the stored message) and stores it. A time zone name is required and is kept with the row; the instant is stored in UTC. 5 s to 366 days ahead, 100 per mailbox. The draft it came from is removed.- When due, the loop signs in with the Dovecot master user (
mail.sso.prepareas the system actor, ADR 0018; the server comes frommail.client.config, now listed insystem_calls) through an unregistered session (gw.OpenOffline) and uses the same hand-off as an immediate send (gw.DeliverRaw: submission, copy to Sent,\Answered/$Forwarded, draft removed). Postfix still enforces login = sender, so a scheduled message cannot do what an immediate one cannot. A 5xx answer marks the rowfailed(kept in Scheduled with the server's reason,webmail.send.failedevent); a network error retries with 1, 2, 4, 8, 16 minutes, then fails. A claim isFOR UPDATE SKIP LOCKED; a sender that died mid-send is retried after 10 min. scheduled.list,scheduled.edit(puts the message back into Drafts with its attachments and deletes the row),scheduled.cancel. Sent rows are history for 7 days with the body emptied.- Undo send is unchanged: a 0-30 s hold in memory of the session (it is delivered when the session closes). It is not durable across a restart of the plugin; the scheduled queue is.
message.snooze {folder, uids, wake_at, timezone}moves the messages to the folderSnoozed(created on first use; a normal folder, so every client and phone sees it) and records the Message-ID. At the time the loop moves the message back to the folder it came from, adds the keyword$Snoozedand clears\Seen, so it arrives as unread, newest, marked. A message deleted meanwhile just is not there.snooze.list,snooze.cancel(back now).
Mail connections per mailbox (w11-36)
The mail server allows ten connections per user and address. A mailbox session holds the command connection only while it
works (given back after 45 s without work and reopened by the next operation) and one IDLE connection (push) only while
a page is looking: the page sends session.watch every 30 s, and a session that heard nothing for 100 s parks IDLE and
wakes by itself on the next request. A second sign-in to the same mailbox from the same panel session returns the
existing session. All sessions of one mailbox share a budget of five connections (gw/conns.go); an open that cannot
get one within 8 s answers "too many open mail connections", never "wrong password". When the budget is full the other
sessions of the mailbox give back at once what nobody uses (a command connection idle for 3 s, the IDLE connection of a
page silent for 45 s), so earlier sign-ins never make a new one wait (walk webmail/14).
Calendar (w11-36)
Events live in the mailbox's own CalDAV calendars on the contacts-and-calendar service (the same sign-in and confinement as
contacts; the service's port is read from the mail module's mail.client.config, never written here). gw/ical.go is the
strict iCalendar reader/writer (512 KB per object, 8 MB and 3000 events per import, text cleaned like mail, ATTACH and
other unmodelled lines never taken from mail or an import) and the repeat-rule expander (DAILY, WEEKLY, MONTHLY, YEARLY with
INTERVAL, COUNT, UNTIL, BYDAY with ordinals, BYMONTHDAY, BYMONTH, BYSETPOS; finer frequencies refused; 200 000 iterations
and 2000 occurrences per query; a window is at most 400 days). A stored rule is capped at COUNT=5000, because the
calendar service itself expands a rule when it stores the event. Times are kept in the event's own zone (VTIMEZONE written),
repeat rules are evaluated on the wall clock of that zone, and the screen draws everything in one display zone chosen in the
toolbar. "This event / this and following / all" are RECURRENCE-ID overrides, UNTIL + a new series, and the master.
gw/invite.go: an iCalendar part in a mail shows Accept / Maybe / Decline; the answer is the standard REPLY to the
ORGANIZER of the invitation (shown to the person, and re-checked on the server), sent through the mailbox's own send path;
updates, cancellations and guests' answers are applied only when the organiser matches. Reminders: a loop looks at the
calendars of mailboxes whose Calendar was opened (cal_watch) once a minute through the master user and raises one bell
notice per due reminder (core.notice.raise, grouped after four); only the last 15 minutes are considered, so an import of
past events raises nothing; cal_fired stops a second notice. Nothing is mailed.
Contacts (w11-35) and the calendar to come
The mail stack has no DAV, so contacts are a separate small service, Radicale (Python, GPL-3.0, plain files per mailbox;
radicale on Debian/Ubuntu, radicale3 from EPEL 9/10 on the RHEL family). It is off until an administrator runs
mail.dav.set {enabled: true} (high risk: plan, step-up, a job). That installs the package (system.apt.ensure), then the agent op
mail.dav.service writes /etc/radicale/config, the sign-in plugin /etc/radicale/rc/rc_auth.py, a systemd drop-in and the mail
host's certificate for it, and starts it on port 5232 with TLS, all interfaces. mail.client.config reports dav (enabled, host,
port) and the webmail Contacts screen shows an explanation (and, for an administrator, a "Switch on" button) while it is off.
- Sign-in is the mail stack's own, never the panel session. The plugin does an IMAP login against Dovecot on 127.0.0.1:993 with
what the client sent: the mailbox address and its password (an app password later: whatever Dovecot accepts), or
address*masteruserand the master password, which is how the gateway signs in for a person who opened webmail without typing a password. The user the service sees is the mailbox address (everything after*is dropped), andrights = owner_onlyconfines it to/<address>/. Proven bylab/tests/dav-isolation.sh(two mailboxes, 16 attempts) and by two mailboxes in the webmail. - The gateway is a DAV client (
gw/dav.go): it addresses only/<own address>/contacts/(MKCOL on first use), over the same verified TLS as IMAP (the mail node's pinned self-signed certificate or a CA one), with the session's own credentials. Actions:webmail.contacts.list/save/delete/import/export/group. Optimistic concurrency by ETag (a phone's change in between gives a clear conflict, not a lost update). - vCards are untrusted data (
gw/vcard.go): one card at most 256 KB, an import 8 MB / 3000 cards, every value stripped of control and bidi-override characters and truncated, e-mail addresses validated, only http(s) URLs kept, group names without separators, what the webmail writes back is generated (vCard 3.0), never echoed; properties the webmail does not model (PHOTO, X-*) are kept as opaque lines so a phone's data survives an edit and are never interpreted or fetched. A card UID that is path-shaped is replaced. - Recipient suggestions come from the address book first, then from the people in the loaded mail.
- Not yet: app passwords (Dovecot's passwd-file passdb takes one password per user; needs a second passdb or SQL), the service behind
the web server on 443 with
/.well-known/carddav(Radicale itself redirects/.well-known/carddavto/on its own port), certificate renewal reaching the service's copy, the firewall opening for 5232, a calendar screen (w11-36 uses the same service: CalDAV collections are allowed already).
Rules (ManageSieve) and vacation
Rules are structured JSON (conditions on from/to/cc/subject/header/size/body; actions fileinto/copy/mark read/flag/label/
redirect/discard/stop), rendered to Sieve by BuildSieve with every value quoted/validated and the rules embedded in a
comment for exact round trip, stored as script rc-webmail and activated through port 4190; the server's own
syntax error is returned verbatim. The rules script is the user's active script; the out-of-office reply lives in a
separate file the mail module owns (~/.rc-vacation.sieve, a per-user before script), so the two never share a file
(mail/012). rules.set never switches off another active script (one written by an older install or another client): it is pulled into
rc-webmail with include :personal before the rules (BuildSieveWith), as is any script the previous rc-webmail already
included; replace_foreign drops them on purpose. Saving a rule therefore cannot lose an out-of-office reply.
vacation.set calls mail.autoresponder.set/.delete as the caller and mirrors the values in settings.
Data (Postgres schema of the module)
identities (owner account + mailbox, email, name, reply-to, signatures; limit key webmail.identities 20),
settings (<= 16 KiB JSON per mailbox, vacation mirror under key vacation), trusted_senders. Keyed by the hosting
account so a mailbox shared by sub-users shows one set.
Verified
See docs/tasks/w4/w4-06-webmail-backend.handover.md (unit + lab results).
Not done / next
Calendar (CalDAV on the same service), app passwords, one-click unsubscribe POST (needs an SSRF-safe fetcher), push, S/MIME/PGP, delegation, attachment
zip, FTS tuning/benchmark on 100k mailboxes, message preview snippets (IMAP PREVIEW), remembered sessions via the vault,
a panel-session-id binding (the actor has no session id; binding is to the principal), per-folder IDLE for several
folders at once, Sieve include integration with the mail module (above).
Remote images (w11-13)
The panel's content-security policy (img-src 'self' data:) is inherited by the sandboxed frame that shows a message, so a
remote https: image never loads in a browser, whatever the frame's own policy says (proved in Chromium by
web/apps/panel/scripts/ui-browser.test.mjs). The panel's policy is not loosened. When the person presses "Show images"
(or trusts the sender) the gateway fetches each image itself (gw/inlineimg.go: the egress guard refuses private,
loopback and metadata addresses, no redirects, PNG/JPEG/GIF/WebP/AVIF sniffed from the bytes, SVG never, 2 MiB each,
40 and 8 MiB per message) and puts it into the message as a data: image.
List previews and the sender card
List rows carry preview, the first words of each message (gw/preview.go): the list fetches the first 2 KB of the
message's own text part (text/plain; else text/html, 16 KB, because head and style blocks often fill the first KB) with
PEEK, one fetch per distinct part path, decodes it (decodeBody, base64 cut to whole groups), turns HTML into text,
drops quoted lines, stray tags in text parts, ruler lines and invisible padding, and keeps 180 characters. A failure
leaves it empty. The list is a container: from 416 px wide a row is who and subject on one line (with marks and when),
the first words under them; narrower, it stacks who and when, the subject and the marks, then the first words. Compact
density keeps the wide row to one line, the first words after the subject. The default width is 460 px. In the reader, the sender's picture and name open the sender card (components/sender-card.tsx):
picture, address, the sender check, Write to them, Show all their mail (from: search), Add to contacts (Contacts opens
with the new contact filled in) and Copy address.
Sender pictures
webmail.sender.pictures {emails} answers {pictures: {address: data URI}} for the list's and the reader's sender
circles; an address without a picture is left out and keeps its letter. Up to 60 addresses per call (trimmed, lowercased,
deduplicated, invalid ones ignored). For each: the person's Gravatar (https://gravatar.com/avatar/<sha256 of the address>?s=96&d=404), else the organisation's own icon for the registrable domain of the address (email.apple.com
-> apple.com, public suffix list): the best <link rel=apple-touch-icon> / <link rel=icon> of https://<domain>/
(or https://www.<domain>/), then /apple-touch-icon.png, then /favicon.ico. Personal-mail providers (Gmail, Outlook,
Hotmail, Yahoo, iCloud, Proton, GMX and the like: one list in gw/senderpic.go) never get the provider's logo. Same rules
as remote images: this server fetches through the egress guard (no private, loopback or metadata address; redirects at
most 3, each re-checked, https only), with no cookie, no Referer and the User-Agent RespireCloud-Webmail/1.0, 5 s per
request, 6 at once per call; PNG/JPEG/GIF/WebP/ICO sniffed from the bytes, SVG never, 48 KB each, 2 MiB per answer. The
call answers within 6 s with what it has and finishes the rest in the background, so the next call gets it. Cache in the
gateway process: per address for Gravatar, per domain for icons; found 7 days, none 1 day, 1 hour after a timeout or a
server error; at most 5,000 entries and 32 MiB, least recently used dropped first; one fetch per key at a time. Privacy:
Gravatar sees the hash of the address and the sender's site sees this server, never the reader; the request reveals no
more than that someone on this server listed mail from that domain. Nothing is logged. Mail in Junk is never looked up
(the client asks only outside Junk). The server owner chooses with the module setting sender_pictures: all (default),
icons (the sender's own site icon only, no address hash ever goes to Gravatar) or off (letters everywhere, nothing
looked up).
Spam, held mail, saved responses and preferences (w12 G2)
webmail.spam.prefs.get/setandwebmail.quarantine.list/release/deleteact on the signed-in mailbox only: they find its id and call the mail module'smail.spam.prefs.*andmail.quarantine.*(listed insystem_calls). Previews (dry_run) pass through to the mail module.webmail.footer.getlets a mailbox read the footer of its own domain; panel users name a domain they manage.webmail.settings.setcheckslanguage,timezone(an IANA name orauto) andreading_pane(right,bottom,off).webmail.template.list/save/deletekeep up to 50 saved responses in the settings document undertemplates;settings.setnever overwrites them.
Webmail address follows the mail host setting (w12 mail-host)
mail.host.resolve (mail module) says which webmail host a domain uses: webmail.<domain>, or one webmail.<shared host's parent> (for example
webmail.respiresoft.com) for every domain on the shared mail host. hosts.go (hostSpecOf) uses it for list, ensure, remove and the hand-off base
(appBase, which falls back to a still-serving webmail.<domain>). The shared host's row has domain = its own host name and no owning account, so any
mailbox address signs in (admits) and webmail.public.resolve returns an empty domain (the sign-in page then needs the whole address). Its DNS record goes
in the shared domain's zone. webmail.on_mail_hosts_changed (event mail.hosts.changed) sets up each distinct address once; addresses no longer used keep
serving so old links work. Removing a domain never removes the shared address. The panel's Webmail page lists the shared address once, with the number of domains.
Connect a phone (ux/mail-scan-to-connect)
Settings, Devices has "Phones and mail apps": the mailbox's app passwords (webmail.connect.phones, webmail.connect.revoke, own mailbox only) and a
"Connect a phone" button (webmail.connect.link, high risk so the sign-in asks for the mailbox password first). The link opens
https://webmail.<domain>/connect/<token>, served by the panel's web layer (internal/api/webmail_connect.go): a server-rendered page with no
script except the copy buttons, a strict CSP, no-store, rate limited per IP (the webmail sign-in limiter; dead links count as failures). Opening it
only looks (webmail.public.connect op peek). A button spends the link: iPhone and iPad get a .mobileconfig (IMAP 993 SSL, SMTP 465 SSL, the new
app password; unsigned, iOS shows "Not verified"); Android gets "Open in the RespireCloud app" (respirecloud://mail?host=..&token=..) and the exact settings
with copy buttons; any phone can use the webmail instead. A used, expired or unknown link is explained in plain words (HTTP 410).
The message list scales to any folder (1.0.52, owner 2026-11-24: "only load whats visible")
lib/list-window.ts + useRows (lib/data.ts) + ConversationList (TanStack Virtual): the scrollbar spans the whole
folder (server total), only the rows on screen plus 4 are in the page, and one window of 25-row pages around the screen
is held (at most 12 while scrolling, 6 once it stops); a jump far away starts a new window there. Unloaded rows are a CSS
skeleton (no elements). The row at the top of the screen keeps its place when new mail arrives or rows above change.
Date headers are a full-width band (day, full date, row count; "N+" while the group continues past the window). Measured
in a 100,000-row harness: first rows 165 ms, 19-24 rows in the page, 4-6 MB of JS memory, 16.7 ms frames while flinging
(the old list at 20,000 rows: 380 MB, 189 ms frames). The gateway keeps each folder's grouping (gw/listcache.go), so a
page or a jump costs about 6 ms. Mailboxes signed in here are listed at the top of the sidebar (one click switches; Add
mailbox); the profile menu no longer switches.
1.0.53 (owner 2026-11-24): date bands are placed with top, never a transform. Sticky positioning works from the box
before transforms, so a translated band slid down its group by the scroll distance and covered rows (live check step
"date bands stay in place while scrolled"). "Add mailbox" opens a small dialog over the mail (AddMailboxDialog, the same
SignInForm as the sign-in page) instead of the full sign-in page; the new mailbox opens once signed in.
Display (1.0.49, owner 2026-11-23)
Settings, Display: every choice applies and saves the moment it is picked (no Save, no plan dialog), and the mail view
reads it again at once (SettingsPage onChanged invalidates the client's settings, identities and folders: Settings has
its own query cache, which is why a change used to need a reload). Choices: language, time zone, list density, group the
list by date (Day, Week, Month, Off; group_by, headers like WhatsApp's from lib/format.ts groupByDate, on the
device's clock), conversations (together or one by one), open a message (next to the list or full width; the old "below"
was dropped and opens next to the list), dark mail, undo send (Off to 30 s). An open message next to the list has a close
button. The old in-client settings view (components/settings.tsx) was unused and is gone. Rows come newest arrival first
and are never re-sorted, so mail moved in later can repeat a date header.
Notifications (browser, opt-in)
Settings, Notifications. Off by default; the browser's permission question is asked by the click that switches "Tell me about new mail" on. Choices (folders, sound, "only when this tab is not open") live in this browser's localStorage per mailbox (lib/notify.ts), not on the server. The pop-up uses the existing live stream (webmail.mailbox.changed, kind exists), fetches the newest message of that folder, asks webmail.message.alert for the same words a push carries (sender, subject, first words, a code) and hands it to the worker (rc:notify), so it has the same buttons and the same per-message tag: a mail announced by the page and by a push shows once. A click opens it. The IMAP IDLE watcher follows one folder: the open one if it is chosen, otherwise the first chosen one. No push when no page of the app is open; that needs Web Push and is not built.
The app asks (1.0.48, owner 2026-11-23: "it never asked me"). The standalone app shows a bar under the app bar
(ui/src/standalone/notify-prompt.tsx) for each signed-in mailbox whose pop-ups or device push are off: "Turn on" asks the
browser in that tap and switches on both the pop-up and the push when the app is closed (/push/subscribe +
webmail.notify.set enabled); "Not now" hides it for 7 days. A browser that blocked notifications, or an iPhone outside the
installed app, gets one line saying what to do (hidden for 30 days after OK). Settings, Notifications still switches each part.
The installed app (1.0.43)
What makes the webmail an app on every OS, on top of the worker and push below:
- Links from outside (
ui/src/standalone/links.ts, one reader): the manifest (webmailManifestExtraininternal/api/webmail_app.go) registers the app formailto:links (?mailto=), the system share sheet (GET,share_*fields) and three shortcuts (Write, Inbox, Search). A notification URL names its mailbox (?mailbox=,cp/notify.go) and, for one message,open/uid(+accountfor another provider's account).launch_handlerisfocus-existing: a link used while the app is open arrives throughlaunchQueue(or the worker'src:openmessage after a notification click) and never reloads the window. The shell hands a link only to the mailbox it names, switching first;AccountPanesswitches to the named account; a message of a mailbox not signed in here is not opened. A mailto: never replaces a message being written. - Remembers like an app: the open mailbox (localStorage
rc.webmail.current, the tab's own choice first) and the open folder per mailbox (rc.webmail.folder.<address>; a folder that is gone falls back to the Inbox). Alt+1 to Alt+5 switch mailboxes (not while typing). - Notifications per mailbox: each signed-in mailbox switches this browser on or off for itself (
/push/statussays which); the title names the mailbox. The icon badge shows the Inbox's unread count while the app is open and the number of notifications showing while it is closed. - Offline and slow networks: the worker keeps the app's hashed files after first use and the last app page, so the app
opens offline and at once (mail itself,
/api/, is never cached). A slow network with no kept page is waited for. A failed request, or a 502/503/504 page from the proxy, marks the link down (lib/online.ts): a bar says so, keeps what is loaded, retries itself (3 s doubling to 30 s, at once when the browser is back online) and reloads everything when it is back. GETs retry twice before giving up; the first load retries by itself. Writes are never retried silently. - Live check after a release:
node modules/webmail/ui/scripts/live-check.mjs [test-mailbox]on the server (15 checks at 128 kbit/s, 300 ms away). 1.0.44 on s1: cold open 20.8 s and 258 KB on the wire (was 60 s and 994 KB before gzip of the app's files and the API's JSON,internal/webui/gzip.go), warm open from the worker's copy 2.3 s.
New-mail notifications with no tab open (webmail push)
Settings, Notifications: switching on "Also when no mail page is open" signs this browser up first (enablePush, the same
as the menu's "Notify me on this device") and says plainly why when the browser refuses; switching it off stops this
device. The pane says whether this device gets them, and "Send a test notification" calls POST /api/webmail/push/test
(Core.PushTest). Until 1.0.38 the switch only saved the preference and no browser was ever signed up.
Webmail used to tell only an open tab (the IMAP IDLE live channel). Now a person can also be told by a Web Push from their own
server, through the PWA work (docs/web-push.md, core.push.send).
- Source. The mail module publishes
mail.message.arrivedfor every delivery (modules/mail/docs.md, "New-mail source"). This module subscribes withwebmail.on_mail_arrived. - The choice is on the server, table
notify_prefs(migration 0006), one row per person and mailbox:enabled,folders(IMAP names, the inbox by default),preview(default off). Actionswebmail.notify.getandwebmail.notify.set(permissionwebmail.settings.manage, set has a dry run). Settings, Notifications has a second block, "Also when no mail page is open", and "Show the subject too". The browser's own pop-up choice for an open page stays in the browser and is unchanged; the folder list serves both. A person is the id the device subscribed under (core.push.senduser_id): the panel principal, orwm:<id>for a mailbox sign-in. A mailbox sign-in that ended takes its devices with it, so the person switches it on again on the next sign-in; rows ofwm:sign-ins untouched for 45 days are deleted. - What is sent (1.0.54, owner 2026-11-24: "if it has otp ... a proper email notification on PC"). With "Show a preview"
on (the default for new choices since 1.0.54; saved choices kept, migration 0008) it reads like Outlook's or Gmail's: the
sender as the title, then the subject and the first words (
snippet, quotes and links left out), or, when the mail gives a one-time code, "Code 482913" and the subject, withcodefor the Copy button. The text is read once per arrival through the mail module's master user (arrivalText, as a scheduled send signs in; read without marking it read), only when someone wants the preview. Codes (findCode,cp/alert.go): 4 to 8 digits or 5 to 12 capitals and digits, taken only next to a word that announces a code, in many languages and scripts written without spaces; years, links, postcodes and order numbers never count. With the preview off: title "New mail for", body "From ". The worker ( app/public/sw.jsshow) adds buttons where the device shows them (Chrome and Edge on a computer, Android): "Copy" (the app's window copies: a worker has no clipboard), "Mark as read" and "Delete" (straight through the app's API with this browser's sign-in; a mailbox not signed in here opens the message instead).tagismail:<hash>per message (alertTag), andwebmail:<mailbox>for a summary, which replaces the older one;urgencynormal;urlis a path on the app the device subscribed at, with?open=<folder>&uid=<n>when it is one message ("/" onwebmail.<domain>, "/mailbox/" on a panel hostname). The page opens that message on load and removes the parameters. - Rate limit. One push per mailbox every 30 seconds. The first message after a quiet spell goes at once; mail arriving inside the window is counted and goes out when it ends as "3 new messages" (no sender, no subject). Kept in memory, so a restart forgets a window: at worst one extra push.
- Which folders. Junk, Spam, Trash, Drafts, Sent and the quarantine never notify (also stripped from a saved choice). Mail that a person's own rules (Sieve) filed into another folder notifies only if that folder is chosen. Per person: one delivery can notify one person and not another on the same mailbox.
- No push on this panel yet / no device:
core.push.sendis called as a system call (declared insystem_calls); any error from it is logged at debug level and skipped, so nothing breaks and nothing is sent. The module never sends anything itself.
Other mail accounts (feat/webmail-external-accounts)
A person can read and send mail from another provider (Gmail, Yahoo, iCloud, a former host, any IMAP/SMTP server) next to their own mailbox. The server does the work: it signs in to the provider and the browser and the phone app only ever talk to their own server. It is the advanced choice (owner 2026-11-23): "Add another mailbox" (folder rail and the mailbox menu) signs in to one more mailbox of this server; the add-mailbox page has a quiet "Advanced: add mail from another provider" link that opens this dialog. The folder rail lists other-provider accounts under "Mail accounts" once there is one. Picking an account shows the same client for that account.
- Whose accounts. For a mailbox sign-in the person is the mailbox (
mailbox:<address>). For a panel user it is the user (user:<principal>). Staff who opened somebody else's mailbox see none (web_sessions.staff). Tableext_accounts(migration 0007) has the servers, the state (untested|ok|auth|unreachable|tls+ a sentence) and the push position (uid_validity,last_uid). No password is kept there. - Passwords (or app passwords, plus an optional separate SMTP password) are kept in the module's vault
(
Host.PutSecret, nameext-account/<id>). They are never returned, logged or audited, and are deleted with the account. OAuth is not built: Gmail, Yahoo, iCloud and Fastmail work with an app password (the dialog says how). Outlook, Hotmail, Live and Microsoft 365 only allow a Microsoft sign-in for mail apps, and Proton needs its Bridge, so discovery marks themunsupportedand the dialog explains this. POP3 accounts are not supported. - Finding the settings (
webmail.account.discover,gw/discover.go), in order: the built-in list of big providers;https://autoconfig.<domain>/mail/config-v1.1.xml;https://<domain>/.well-known/autoconfig/mail/config-v1.1.xml; the shared ISPDB (autoconfig.thunderbird.net/v1.1/<domain>); the domain's MX (Google Workspace and Microsoft 365 are recognised, otherwise the MX host's own domain is looked up in the ISPDB); RFC 6186 SRV (_imaps,_imap,_submissions,_submission); Microsoft autodiscover (POX, no credentials); thenimap.|mail.andsmtp.|mail.names that exist. Every HTTP request goes through the egress client (HTTPS only, re-checked redirects, 256 KiB). Plain text servers and IP literals are never suggested. Nothing found: the person types the servers in. - Test before saving.
webmail.account.testand.addsign in once to IMAP and SMTP (in parallel, 40 s) and answer per side in plain words: "The password was refused...", "The server imap.x didn't answer on port 993...", "...didn't start a secure connection. Try the other security setting...", "The server name ... doesn't exist", certificate problems..addsaves only when both work..updatetests a new password or new servers before saving them,.checkis "Try again",.removehas a plan (the mail stays at the provider). Each action has a JSON schema, the permissionwebmail.accounts.manage(also given to mailbox sign-ins) and an audit entry with no secret; add, update and remove have a dry run. - Limits. 10 accounts per person. 20 tests or adds per person per 10 minutes. After a failed sign-in the account waits 30 s, doubling up to 15 minutes. A refused password waits 15 minutes and is not retried by itself until the password is changed or the person presses Try again, so the provider does not lock the account.
- The dial rule (
gw.Guard, every IMAP/SMTP connection of an account and the push watcher). Only what the egress policy allows: public unicast addresses, plus the module settingegress_allow(an administrator's list of private CIDRs or hosts). Never one of this server's own addresses (its interfaces), unless the name is this server's own mail host (the mailbox'smail.client.confighost). Ports 25, 143, 465, 587, 993, 2525 or 1024 and above. The dial goes to the checked address (no DNS rebinding). TLS is verified against the system roots and security is SSL/TLS or STARTTLS, never plain. An untrusted certificate is accepted only for hosts an administrator lists inuntrusted_cert_hosts(the settings description warns), or when a panel administrator passesallow_untrusted_certificate(the plan warns). Mailbox sign-ins are never administrators, so the webmail app shows that choice only to an administrator. - Using it like a mailbox. The mail actions take an optional
account(folders, list, conversations, search, read, source, attachments, flags, move, delete, archive, spam, reply template, drafts, send, undo send, uploads, watch, receipts, notify).sessXproves the signed-in mailbox first, then opens or reuses the account's gateway session (gw.Config.External, owner<principal>|ext, closed with the sign-in). Sending goes through the account's own SMTP (PLAIN, or LOGIN when that is all the server offers), only as the account's address, and is filed in its Sent folder. The undo window works, but its hold stays in memory: it is not written down like a local mailbox's hold. Rules, out-of-office, contacts, calendar, footers, scheduled send and snooze are this server's own; the gateway refuses them for an account (gw.ErrLocalOnly), their schemas take noaccount, and inside an account the client hides Snooze, Send later, Scheduled and invitation answers. - Live updates and push. The account's IDLE watcher emits
webmail.mailbox.changedwithaddress= the signed-in mailbox andaccount= the account id, so the app's event filter passes it and the page reloads only that account. For push with no page open,cp/extwatch.gokeeps one IDLE connection on the inbox of each account that somebody switched on ("Tell me about new mail" in the account's menu =webmail.notify.set {account}, rownotify_prefsmailboxext:<id>). There are at most 200 such connections per process. It polls with NOOP when the server has no IDLE and renews IDLE every 25 minutes. New UIDs go into the same 30 second window as local mail; the push is titled "New mail in" and its link opens ?account=<id>&open=INBOX&uid=<n>. The last UID is stored, so a restart never announces old mail. A refused password stops the watcher. If this device has no push yet, the toggle first offers to switch it on (the "Notify me on this device" flow). - Not done: OAuth (Google, Microsoft), POP3, "send as" aliases of an account, push for folders other than the inbox,
an undo-send hold that survives a restart, a separate SMTP password in the dialog (the API takes
smtp_password).