Mail

Mail server with domains, mailboxes, aliases, forwarders, catch-all, autoresponders, DKIM/SPF/DMARC/MTA-STS and queue control.

Available mail version 1.0.1 Part of Mail and webmail

Actions

109 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.

ActionWhat it doesRiskPreview
mail.server.enable Enable mail on a server critical
mail.hostname.ensure Certificate for a mail hostname medium
mail.server.config.apply Apply mail server settings high
mail.options.get Mail server options (read) low No dry run
mail.relay.set Send mail through a relay high
mail.relay.test Send a test message medium
mail.filters.set Spam filter and antivirus high
mail.server.services Size the mail filters for this server high
mail.dav.set Contacts and calendar sync high
mail.dkim.selector.set Default DKIM selector low
mail.config.status Hand-edited mail files (read) low No dry run
mail.config.adopt Keep a hand edit on top of the panel's configuration medium
mail.config.reapply Render the panel's version again medium
mail.config.reset Reset a file to defaults medium
mail.config.unmanage Hand a file off to the administrator high
mail.server.selftest Mail server self-test (read) low No dry run
mail.server.get Mail server settings (read) low No dry run
mail.reconcile Reconcile mail servers medium
mail.domain.add Add a mail domain medium
mail.domain.list List mail domains (read) low No dry run
mail.domain.get Get a mail domain (read) low No dry run
mail.domain.delete Remove a mail domain high
mail.domain.dns.check Check mail DNS records (read) low No dry run
mail.domain.dns.fix Publish mail DNS records medium
mail.domain.dns.preview Preview a domain's mail DNS records (read) low No dry run
mail.dkim.rotate Rotate the DKIM key medium
mail.dmarc.set Set DMARC policy medium
mail.mtasts.set Set MTA-STS and TLS-RPT medium
mail.mtasts.check Check that MTA-STS works (read) low No dry run
mail.tlsrpt.summary TLS-RPT reports of a domain (read) low No dry run
mail.bulk.checklist Bulk sender checklist (read) low No dry run
mail.bulk.headers One-click unsubscribe headers for a message low
mail.bulk.unsubscribe Record a one-click unsubscribe low
mail.bulk.suppressed Recipients who unsubscribed (read) low No dry run
mail.warmup.get New-server warm-up (read) low No dry run
mail.warmup.set Turn the warm-up ramp on or off medium
mail.dane.get DANE status (read) low No dry run
mail.dane.set Turn DANE on or off medium
mail.catchall.set Set the catch-all medium
mail.mailbox.create Create a mailbox medium
mail.mailbox.list List mailboxes (read) low No dry run
mail.mailbox.update Change a mailbox medium
mail.mailbox.delete Delete a mailbox high
mail.mailbox.password.set Reset a mailbox password medium
mail.apppw.create Make an app password medium
mail.apppw.list List app passwords (read) low No dry run
mail.apppw.matches Is this password an app password (read) low No dry run
mail.apppw.revoke Revoke an app password medium
mail.connect.create Make a link to connect a phone medium
mail.connect.peek Is this phone link still good (read) low No dry run
mail.connect.redeem Use a phone link medium No dry run
mail.alias.set Create or change an alias low
mail.alias.list List aliases and forwarders (read) low No dry run
mail.alias.delete Delete an alias low
mail.forwarder.set Create or change a forwarder low
mail.forwarder.delete Delete a forwarder low
mail.autoresponder.set Set an autoresponder low
mail.autoresponder.get Read a mailbox's autoresponder (read) low No dry run
mail.autoresponder.delete Delete an autoresponder low
mail.queue.list List the mail queue (read) low No dry run
mail.queue.retry Queue: retry messages medium
mail.queue.hold Queue: hold messages medium
mail.queue.release Queue: release messages medium
mail.queue.delete Queue: delete messages high
mail.queue.flush Queue: flush medium
mail.limit.set Set outbound limits medium
mail.account.hold Hold outbound mail of a mailbox medium
mail.account.release Release a held mailbox medium
mail.autohold.list Mailboxes held for sending too much (read) low No dry run
mail.autohold.release Release a held mailbox medium
mail.autohold.discard Discard held mail high
mail.mailbox.burst.set Allow a mailbox to send bursts medium
mail.dmarc.summary DMARC reports of a domain (read) low No dry run
mail.reputation.get Reverse name and blocklist status (read) low No dry run
mail.reputation.check Check reverse name and blocklists now low No dry run
mail.reputation.set Reputation check settings medium
mail.deliverability.fix Fix a deliverability finding medium
mail.ptr.fix Set the reverse name of a sending address medium
mail.sso.prepare Single sign-on credentials for webmail medium No dry run
mail.client.config Mail client settings (read) low No dry run
mail.names.repair Repair mail names that point at the wrong server medium
mail.config.reset_all Reset the whole service to defaults high
mail.config.snapshot.list Snapshots before resets (read) low No dry run
mail.config.snapshot.restore Undo a reset (restore a snapshot) high
mail.config.history.list Earlier versions of a file (read) low No dry run
mail.config.history.diff Compare an earlier version (read) low No dry run
mail.config.history.restore Restore an earlier version of a file high
mail.unmanaged.scan Scan now for objects made outside the panel low No dry run
mail.unmanaged.list Objects made outside the panel (read) low No dry run
mail.unmanaged.ignore Ignore or un-ignore an unmanaged object low
mail.unmanaged.adopt Adopt an object made outside the panel medium
mail.unmanaged.remove Remove an object made outside the panel high
mail.dkim.import Import a DKIM key from another server high
mail.maildir.import Copy a Maildir into a mailbox high
mail.spam.get Spam and virus protection (read) low No dry run
mail.spam.set Change the spam protection high
mail.spam.prefs.get A mailbox's spam settings (read) low No dry run
mail.spam.prefs.set Change a mailbox's spam settings low
mail.quarantine.list Held mail (read) low No dry run
mail.quarantine.release Release held mail low
mail.quarantine.delete Delete held mail medium
mail.pop3.set Turn POP3 on or off medium
mail.domain.names.ensure Give a domain its own mail names medium
mail.client.profile Apple mail profile (read) low No dry run
mail.host.get Mail host setting (read) low No dry run
mail.host.check Check the mail host again medium
mail.host.set Choose the mail host high
mail.domain.host.set Use the server's mail host or the domain's own medium
mail.host.resolve Mail and webmail host of a domain (read) low No dry run

Permissions and limits

Permissions

  • mail.server.manage Manage the mail server
  • mail.server.view View the mail server
  • mail.domain.manage Add and remove mail domains
  • mail.domain.view View mail domains
  • mail.dkim.manage Manage DKIM keys
  • mail.dmarc.manage Manage DMARC policy
  • mail.mtasts.manage Manage MTA-STS and TLS-RPT
  • mail.mailbox.manage Create, change and delete mailboxes
  • mail.mailbox.view View mailboxes
  • mail.mailbox.password Reset mailbox passwords
  • mail.alias.manage Manage aliases, forwarders and the catch-all
  • mail.autoresponder.manage Manage autoresponders
  • mail.queue.view View the mail queue
  • mail.queue.manage Act on the mail queue
  • mail.limit.manage Set outbound limits
  • mail.abuse.manage Hold and release senders
  • mail.client.view View mail client settings
  • mail.spam.manage Change a mailbox's spam settings and release held mail

Plan limits

  • mail.domains Mail domains
  • mail.mailboxes Mailboxes
  • mail.forwarders Forwarders
  • mail.mailbox_quota_mb Largest size of one mailbox
  • mail.storage_mb Mail storage of the account (all mailbox sizes added up)
  • mail.sends_per_hour Outgoing mails per hour for each mail domain of the account (0 = server default)
  • mail.sends_per_day Outgoing mails per day for each mail domain of the account (0 = server default)

Engineering notes

Generated from modules/mail/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.

Desired state lives in the panel DB (mail_* tables, mailboxes). Every mutation re-renders the whole node configuration in the control plane (cp/render.go, templates in templates/) and sends it to the agent with mail.files.apply; the agent writes only a fixed set of file kinds (sdk/agentop/mail.go), atomically, validates with postfix check / doveconf -n / rspamadm configtest / sievec, restores the previous files on failure, and reloads only the services whose files changed. Idempotent; mail.reconcile re-applies everything.

Decisions

  • Storage: all mailboxes are virtual users owned by one vmail system user: /var/vmail/<domain>/<local>/Maildir. Per-account Unix ownership was rejected: Dovecot LMTP/IMAP run as one uid and hosting accounts are shell users who should not read mail. Quotas are Dovecot maildir quotas (userdb_quota_rule), not filesystem quotas.
  • Passwords: bcrypt ({BLF-CRYPT}$2a$10$) hashes in the panel DB, exported to a Dovecot passwd-file (/etc/dovecot/rc-users, 0640 root:dovecot). One password store: Postfix authenticates through Dovecot SASL. Argon2 was skipped (memory cost per login under Dovecot's auth worker, libsodium dependency).
  • Maps: Postfix texthash: files (no postmap step) for domains, mailboxes, aliases, sender-login, held senders.
  • DKIM: per-domain RSA keys generated on the node (/var/lib/rspamd/dkim/<domain>.<selector>.key, 0640 root:_rspamd); the private key never enters the DB, results, logs or events (only the public key is stored). Rspamd dkim_signing + arc use dkim_selectors.map. Ed25519 not yet.
  • Rotation (two steps): mail.dkim.rotate makes a pending key and publishes it; activate=true (or immediate) switches signing and keeps the old selector published 7 days (retired, removed by mail.reconcile).
  • TLS: self-signed cert at /etc/rc-mail/tls/{fullchain,privkey}.pem until ssl installs one at the same path.
  • Ports: 25 (STARTTLS), 587 (STARTTLS, auth), 465 (implicit TLS, auth), 143/993 IMAP, 4190 ManageSieve. Submission requires login = sender (reject_sender_login_mismatch) and refuses held / outbound-disabled senders.
  • Sieve layout (mail/012): two owners, two files. The mail module owns ~/.rc-vacation.sieve (the out-of-office vacation, date window via the date extension with a UTC-offset timezone; a comment-only script when off), rendered for every mailbox on every sync and loaded by Dovecot as a per-user sieve_before script (after the global spam filter, so the reply runs ahead of the user's rules and a rule that files or discards a message never silences it). The user's active script ~/.dovecot.sieve belongs to ManageSieve clients (webmail saves its rules as script rc-webmail and activates it); the mail module never writes or includes it, so neither side can overwrite the other and there is no config_drifted on a file nobody edited. Mailboxes written by the old layout are migrated by the agent on the next sync: the old managed wrapper is removed, and webmail rules that had overwritten it move to ~/sieve/rc-webmail.sieve and become the active script again.
  • Catch-all (mail/011): @domain -> target sits in virtual_alias_maps, which Postfix reads before the mailbox map and again for every alias destination. Each mailbox of a catch-all domain therefore gets an identity line (info@d info@d) ahead of it, so existing mailboxes and alias destinations are never swallowed; a mailbox that is itself an alias key keeps that mapping.
  • Auto-provision: domains.created -> mail.on_domain_created only when the single mail server has auto_provision on (never publish MX for a domain nobody asked mail for). domains.deleted removes the mail domain but keeps the maildirs on disk (orphans under /var/vmail/<domain>).
  • Limits: mail.domains, mail.mailboxes, mail.forwarders (Reserve/Release, compensated on failure).

DNS records (per mail domain)

MX @ -> 10 <hostname>.; SPF @ TXT v=spf1 mx ~all; DKIM <selector>._domainkey TXT v=DKIM1; k=rsa; p=… (pending/ active/retired selectors); DMARC _dmarc TXT (starts p=none); MTA-STS _mta-sts TXT + mta-sts CNAME -> host and TLS-RPT _smtp._tls TXT when enabled; autoconfig and autodiscover CNAME -> host. Publishing calls dns.record.upsert_managed with {domain, owner_module:"mail", key, record:{name,type,ttl,value}} for each record (assumption from docs/specs/dns.md §6; zone resolved by domain since w2-01 may use zone_id). If that call fails for any reason (module missing, zone not hosted here) the action returns dns: {published:false, records:[…]} to copy. The DKIM value can exceed 255 chars: the dns module must split it into TXT strings. MTA-STS policy text is written to /var/lib/rc-mta-sts/<domain>/.well-known/mta-sts.txt and served by the panel's web server at https://mta-sts.<domain>/.well-known/mta-sts.txt (see "Deliverability batch" below). TLS-RPT _smtp._tls TXT points at tlsrpt@<domain>.

Verified in the lab (2026-10-09, FAKENET=full, Ubuntu 24.04, Postfix 3.8.6, Dovecot 2.3, Rspamd 3.8.1)

enable (apt + config + self-test all green) · domain add (DKIM + files) · inbound from "outside" to a mailbox read over IMAPS · bad IMAP password refused · submission 587 with auth -> relay -> Mailpit, DKIM-Signature + ARC seal present and dkim.verify = True (also after rotation, new selector) · sender mismatch 553 · open relay refused · no auth without TLS · alias, forwarder with keep-copy, catch-all, loop rejected, autoresponder reply received, held and send-disabled senders rejected, quota-exceeded -> 552 bounce · usage via doveadm · queue list/hold/release/retry/delete/flush · dry-run config diff · domain deletion event keeps the maildir.

Not done (follow-ups)

Relays/smarthost per domain, IP pools, suppression lists, send API/webhooks, distribution lists, raw Sieve/filters UI, mail logs, IMAP import, per-mailbox/domain outbound limit enforcement (stored; only node limit via Rspamd ratelimit + Redis, and a per-IP submission rate are enforced), auto-hold on abuse, mailbox rename, quota warnings at 80/90 %. (App passwords per phone, POP3, ClamAV, the phone QR code and mobileconfig, and the panel screens are built: removed from this list 2026-11-24.)

Moves (w11-09)

A mail domain moves between mail servers with its account: mail.move.plan|copy|cutover|abort|purge (internal, called by the cluster module's move; docs in modules/cluster/docs.md). mail_relays marks a domain on a node as hold (queued, the freeze) or forward (relayed to the node that holds it now: transport_maps + relay_domains in the node's Postfix); mail_kept the copy an old node keeps until purge_source; mail_moves the phase of each domain of a running move. mail.names.repair repairs mail names that name a server which does not hold the mailbox.

Contacts and calendar service (Radicale) behind a guard (w11-48)

The problem. The service expands a repeat rule when it stores an event (to index its time range). Measured in the lab against the service as a signed-in mailbox user, before the guard: FREQ=DAILY;COUNT=999999999 from year 2000 = 13.0 s of CPU for one PUT; FREQ=SECONDLY;COUNT=999999999 = no answer after 40 s (the service's threads stayed busy and a restart waited 90 s for them); FREQ=DAILY;UNTIL=99991231 = 36 s; FREQ=DAILY;BYMONTH=2;BYMONTHDAY=30;COUNT=1 (a day that never happens) = 30 s; the same endless = no answer. The service sat on its own public port with nothing in front of it. After: each of these is refused with 403 in 7-16 ms. Where it lives. Three layers, each doing what only it can:

  1. The web stack (web.panel_host.ensure with upstream: dav, nginx block webPanelRenderDAV): the mail host name on the standard HTTPS port with the certificate of the ssl module (a renewal rewrites the files and reloads nginx; the service holds no certificate copy any more), /.well-known/carddav and /.well-known/caldav redirect to /; request time limit 20 s, body limit 10 MB, a rate per mailbox (the Basic user name, master-user form included: 120 requests/s burst 400, 60 writes/s), at most 10 requests at once per mailbox and 40 per address, requests with no sign-in 10/s per address; answers 429.
  2. The guard inside the service's process (rc_guard.py, started by rc_serve.py, which wraps the service's WSGI application): a PUT/POST body is read once (up to 10 MB), checked, and handed on, so the filter covers one event, a PUT of a whole calendar and an import alike and nothing reaches the service's expander unchecked. Chosen over a filter in nginx (no body inspection without a module that is not on every distribution) and over a separate proxy the agent would run (a second process, a second port, a second thing to restart and to forget); the plugin API of the service has no body hook, the WSGI seam is stable across versions. Because it is in the process, even a request that bypasses nginx on the loopback port is checked.
  3. The resource slice rc-dav.slice (CPUQuota 100 %, MemoryHigh 256 M, MemoryMax 384 M, TasksMax 128, Nice 10, OOMScoreAdjust 500): what still gets through cannot take more than one core, so mail delivery (Postfix, Dovecot, Rspamd in other slices) keeps flowing. Bounds (the webmail's own, modules/webmail/gw/ical.go): FREQ DAILY/WEEKLY/MONTHLY/YEARLY only; only INTERVAL (1-1000), COUNT (at most 5000), UNTIL, BYDAY, BYMONTHDAY, BYMONTH, BYSETPOS, WKST; one rule per event of at most 600 bytes; at most 3000 events and 1000 EXDATE/RDATE values per request; a finite rule may walk at most 5000 repeat periods and 200 years from its start; a rule that can never happen (30 February) is refused; a daily or weekly rule limited to months or days of the month needs an end date (otherwise the service would search up to the year 9999). Endless rules (FREQ=DAILY, what every phone creates for "every day") are allowed. Rules that expand for long (endless, or more than 300 periods) are run one at a time (a second waits up to 2 s, then 503 with Retry-After). Consequence: a phone event with BYWEEKNO / BYYEARDAY / BYHOUR or COUNT over 5000 is refused with a plain reason in the answer body (the webmail would not show it expanded either). The answer is 403 with the CalDAV valid-calendar-data precondition. The port. The service listens on 127.0.0.1:5232 in plain HTTP; the firewall never opens it (the mail preset lists no 5232) and another machine on the lab network cannot connect. mail.client.config reports dav.port = 443 and base_url = https://<host>/; the webmail gateway reads that (no change in the webmail). mail.dav.set needs the web server on the mail server's own machine. Proved by lab/tests/dav-guard.sh and lab/tests/dav-isolation.sh (32/32 through the standard port).

The real client address of a phone's sign-in (w11-60)

The contacts and calendar service signs in to Dovecot from the machine itself, so every failure used to be logged as rip=127.0.0.1 (nothing banned the client, nothing could say where an app password was used). Now:

  • nginx (the standard HTTPS port) sets X-RC-Client (the address it saw) and X-RC-Key; the key is a random string in /etc/radicale/rc/proxy.key (0400, service user) and /etc/rc-dav/nginx-key.conf (0600 root, included by the mail host's nginx block). The guard inside the service (rc_guard.client_ip()) accepts the address only with the right key; X-Forwarded-For is never believed, so a shell user sending a request straight to the loopback port is seen as the machine.
  • The sign-in asks Dovecot's auth service over auth-rcdav, a socket only the service user can open (mode 0600), with the client's address (the answer also says which app password matched: the passwd-file extra field rc_slot=N of the slot files). A refused sign-in is repeated once, in the background, on the IMAP port from 127.0.0.2 with the address in the IMAP ID command, so Dovecot's own imap-login ... (auth failed ...) rip=<client> line (what the ban rules read) names the client. Dovecot trusts the ID only from login_trusted_networks = 127.0.0.2 (/etc/dovecot/rc-dav.conf, included by the main file); an nft rule in its own table rc_dav_trust (rc-dav-trust.service, Before=dovecot) refuses every connection from that source made by anyone but the service user, so a customer's shell cannot forge an address. The trust file is written only after the rule is loaded and checked, and removed when the service is turned off; mail.dav.set says client_address: not forwarded: <why> when it cannot be put in place.
  • Last use: the service notes time, mailbox, app password, address (at most one line a minute per triple) in /var/lib/radicale/rc-lastuse; the agent op mail.dav.lastuse hands the lines over when app passwords are listed. Only contacts and calendar sign-ins are recorded; the address is the one the web server saw (a phone's mobile-network address is shared and can change), the screen says so.
  • Dovecot's own penalty delay now applies to a repeat offender's address, so a guessing client waits longer for each wrong password.

Deliverability batch (w11-200)

Source: docs/research/mail-deliverability-2026.md (what Gmail, Yahoo and Microsoft ask for) and the 13 findings of the 2026-10-20 live run (r108-mail). What is checked by software and what only the sender can do is said in plain words in every finding.

  • Outgoing port 25 (001). Agent op mail.net.check connects (no SMTP, no mail) to three big mail servers on port 25 and to dns.google:443 as a control: open, blocked (control works, port 25 does not) or unknown (no internet). Runs with the install self-test, with mail.reputation.scan every 24 h and on Check now; the answer is in mail_net. A blocked port with no relay is a bad finding that names the provider's way to get it opened (cp/provider_guide.go: Hetzner limits page after a month and the first invoice, OVH, DigitalOcean, Vultr, Akamai, AWS, Google Cloud, Azure; lines the research could not confirm at the provider say so) and points to mail.relay.set; with a relay it is an info. The provider is recognised from the default reverse names.
  • Reverse name, IPv4 and IPv6 (002, 003, 012). mail.reputation.check asks 1.1.1.1, 8.8.8.8 and 9.9.9.9 (not the node's resolver) for the PTR of every public IPv4 and IPv6 address, forward-confirms each name (A or AAAA through public resolvers) and compares with the HELO name. The node's own answer is kept separately (local_ptr) and only mentioned when it differs. Findings: no_ptr, ptr_mismatch, ptr_not_confirmed (forward missing), ptr_not_everywhere (resolvers disagree, a change still spreading), ptr_local_only (no public resolver reachable). They say exactly what to set and that the A/AAAA must exist first; an IPv6 address without PTR offers inet_protocols = ipv4. Blocklists are asked for IPv6 too, but only the lists that publish IPv6 listings (Spamhaus, s5h); the others are skipped for IPv6 and the result says so (list_skipped_ipv6).
  • Setting the PTR (002). cloud.rdns.set {ip, name, connection_id?} (cloud module, plan first) finds the server that owns the address across the admin's compute connections and sets the PTR through the driver: Hetzner Cloud change_dns_ptr, Vultr ipv4|ipv6/reverse, Akamai PUT /networking/ips/{ip} rdns, DigitalOcean by renaming the droplet (IPv4 only; the plan says so). mail.ptr.fix {node_id, ip} calls it for one of the node's own addresses. OVHcloud has an API for it but the panel holds no OVH connection kind: OVH stays guided.
  • MTA-STS (004). web.panel_host.ensure {upstream: "mtasts"} makes a static vhost for mta-sts.<domain> (HTTPS, 200, text/plain, no redirect, /.well-known/mta-sts.txt only) and ssl.cert.issue (target panel) a certificate for exactly that name. New mail domains start in testing with max_age 604800 (enforce: 2592000). The _mta-sts TXT is published only after the agent has fetched the policy over HTTPS like a sender (mail.mtasts.fetch: certificate verified, no redirect, bounded; compared with the text the panel wrote); enforce is refused until then. The id is a hash of the policy text, so it changes exactly when the policy does. mail.mtasts.scan (every 30 min) serves and verifies new domains (retry every 6 h, recheck daily) and raises mail.mtasts.broken once when a working policy stops being served. mail.mtasts.check shows the live fetch, the TLS-RPT summary and whether enforce is advisable (14 days of reports without failures). Needs the mail server to be the panel's own server (the web module drives nginx only there); elsewhere the finding says what to serve by hand.
  • TLS-RPT (005). tlsrpt@<domain> is an alias to the DMARC report mailbox, rendered whenever MTA-STS is on or a TLS-RPT address is set (a mailbox or alias of that name wins). The DMARC collector tells the two apart; TLS-RPT JSON (plain or gzip, size and count bounded, only for hosted domains) goes to mail_tlsrpt_reports; mail.tlsrpt.summary explains the failure types in words.
  • postmaster@ and abuse@ (013). Aliases to the oldest mailbox of the account (else the owner's contact address, via accounts.get and core.principal.get as the system), made at domain add, at the first mailbox and by mail.roles.scan (every 6 h) for older domains; roles_done makes it once. mail.alias.delete of either shows the warning in its plan and refuses without acknowledge_required_address. A mailbox of that name replaces the alias.
  • Bulk senders (007). DKIM signs List-Unsubscribe and List-Unsubscribe-Post (sign_headers written out). mail.bulk.headers, mail.bulk.unsubscribe, mail.bulk.suppressed (AES-GCM sealed token per domain, no readable address, domain-bound, expiring) and mail.bulk.checklist (SPF, DKIM size, DMARC and reports, reverse name, TLS, signed headers, one-click, complaint rate with Postmaster Tools / SNDS / JMRP, warm-up). There is no send API yet: the HTTPS endpoint that receives the one-click POST is the sending application's, calling mail.bulk.unsubscribe.
  • Warm-up (008). A node younger than 35 days sends within a per-mailbox ramp (day 1-2: 50, 3-4: 100, 5-6: 200, 7-8: 400, 9-10: 800, 11-12: 1500, 13-14: 3000, 15-21: 6000, 22-28: 12000, 29-35: 25000 a day; an hour holds a third), rendered into Rspamd's ratelimit and held below any explicit node limit; over the limit the client is told to try again, nothing is lost. mail.warmup.get is the plain view, mail.warmup.set switches it for a server that moved with its history. Rspamd's counters use the open Valkey on the same server (mail.valkey.probe: unauthenticated 127.0.0.1:6379, database 3), set by mail.warmup.apply (every 6 h and at install); redis_url still wins. Per-domain age is shown but not enforced separately (Rspamd's selector is the sender).
  • DMARC progression (009). mail.dmarc.summary carries progress: none, quarantine 10%, quarantine 100%, reject; a step is offered after 14 days at the current step (dmarc_changed_at), reports covering them, 20+ messages and 99% passing, with the DNS change as the existing mail.deliverability.fix plan (now with pct).
  • First report and hygiene (010, 011). The install result carries the first reverse-name, port 25 and blocklist findings; zone_info explains each blocklist. Postfix: disable_vrfy_command, smtpd_etrn_restrictions = reject, smtpd_discard_ehlo_keywords = etrn, smtpd_tls_received_header, smtp_destination_concurrency_limit = 5, smtp_destination_recipient_limit = 50. Not done: postscreen, per-IP smtp_helo_name, cipher pinning.
  • DANE (006). mail.dane.scan (every 10 min): the TLSA 3 1 1 of the certificate Postfix presents is published at _25._tcp.<host> only when the host's zone is hosted by the panel's DNS, signed, and a validating public resolver accepts the chain (agent mail.dane.probe); otherwise mail.dane.get says which step is missing and shows the record. After a renewal the old key stays in the record set for 14 days. The renewal is detected within ten minutes, not before: a sender that validates DANE may defer for that long (the certificate module issues a new key at every renewal). Outgoing smtp_tls_security_level = dane only when the node's loopback resolver validates. mail.dane.set turns it off.

Mail like a real provider (w12 G1)

Handover: docs/tasks/w12/g1-mail.handover.md. Decision record: docs/adr/ ("mail: client names per domain, MX on the server host"). People's pages: docs/guides/mail-admin.md, docs/guides/mail-people.md.

Spam and virus protection (Rspamd is the engine)

  • Levels. Junk (default 6), held (default 10, only with the quarantine on) and refused (default 15). The held level must lie between the other two; mail.spam.set refuses anything else with a plain sentence. A mailbox may set its own Junk level (mail.spam.prefs.set, default_level goes back to the server's).
  • Learning. Bayes is global (one set of statistics) or per_user. Moving a message into Junk teaches spam, out of Junk teaches ham: Dovecot IMAPSieve runs rc-bayes and rc-fuzzy (links to rspamc) against the controller socket /run/rspamd/rc-controller.sock (0660 _rspamd:vmail; no TCP 11334). Two links because a Sieve script may use one pipe program once. Bayes skips messages under 11 tokens. Fuzzy adds show after the storage sync.
    • Rspamd runs as _rspamd (systemd User=), so it may only give the socket a group it belongs to: the agent puts _rspamd into vmail's group and restarts Rspamd once when it adds it (rspamdControllerAccess). Without it Rspamd logs "cannot change owner" and the socket stays _rspamd:_rspamd, which Dovecot cannot open. Side effect: Rspamd can list /var/vmail (0750).
    • The learning scripts are compiled with sievec -c /etc/dovecot/dovecot.conf. Without -c, sievec asks the running Dovecot, which does not load the new file's sieve_imapsieve/sieve_extprograms before the reload, so the scripts were refused and the apply rolled back (walk mail 1). Checked on Ubuntu 26.04's Dovecot 2.4.2: the 2.4 block (sieve_plugins {}, top-level mailbox Junk { sieve_script ... }, imapsieve_from Junk) compiles, and an IMAP MOVE into and out of Junk runs learn_spam and learn_ham with the user's address.
  • Lists and rules. The server's own fuzzy store, OpenPhish and PhishTank maps, SpamAssassin rules through Rspamd's module (daily mail.spam.update: sa-update, then only the rules Rspamd can run are written, the eval rules that log about 50 lines a message are dropped), greylisting (on: from the greylist level, 4 points, up to the refused level, the first message from a new sender gets 451 and waits five minutes; mail from the server's own networks, private addresses included, and signed-in senders is never delayed), ClamAV (existing switch). Each switch is on by default: greylist, fuzzy, phishing, sa_rules, quarantine.
  • Spamhaus and the other DNS blocklists are on. Spamhaus is free only for small non-commercial volume and refuses queries through big public resolvers (Rspamd then reports DBL_BLOCKED_OPENRESOLVER and skips those lists). Over about 100,000 messages a day, or commercial use, Spamhaus wants a DQS key. There is no setting for the key yet; the screen only says this in words (spamhausNote in cp/spam.go).
  • Per mailbox. Spam level, what happens to spam (junk, tag the subject, refuse at the door), allow list (never spam) and block list (always Junk), at most 200 entries each. "Refuse" and the lists are a Lua postfilter (rspamd.local.lua) that acts only for mail to that one address; Rspamd's settings expression parser breaks on quotes and commas, hence Lua. The allow map's keys are recipient>sender (a map line is key, space, value: the old recipient sender keys never matched).
  • Outgoing. Outgoing mail is scanned too. After outbound_spam_hold (default 5) refused spam messages from one mailbox in an hour the mailbox is held automatically (the existing hold: queued, never bounced, released by an admin).

Quarantine ("Spam and held mail")

  • Mail scoring at or above the held level goes to the hidden Dovecot folder RC-Quarantine/Held through the mailbox's own Sieve script (~/.rc-vacation.sieve now has spam handling first, then the vacation reply). Not in the inbox, not in Junk, not in the mailbox quota view of the person's app.
  • mail.quarantine.list (a mailbox, a domain, or everything the caller may see), mail.quarantine.release (moves to the inbox and teaches ham unless learn is false) and mail.quarantine.delete (permanent). Permission mail.spam.manage is for admin, reseller, user and subuser: a person sees only their own mailboxes.
  • Release and delete act only on messages still held: a second call (another tab, a retry) does nothing and answers done: 0, already: n. After doveadm move the agent checks the held folder and expunges whatever is still listed (the copy in the inbox is committed first), so a released message leaves the list in the same step. Both previews name each message (subject and sender) and say which are no longer held; the screen asks before either and drops the rows at once.
  • mail.quarantine.scan runs every 6 hours: deletes mail past quarantine_days (default 30, 1 to 365; once a day) and, for mailboxes that asked, saves a daily list of held mail into the inbox (doveadm save, agent mail.message.save).
  • Not built: an admin-wide digest to one address.

POP3

mail.pop3.set switches POP3 on 110 (STARTTLS) and 995 (TLS). On by default. IMAP is not affected. When off, the _pop3s SRV record says "not offered" (0 0 0 ., RFC 6186) and the Mail apps pages leave POP3 out. The firewall preset opens all standard ports.

Names and client set-up per domain

  • Each mail domain publishes mail.<domain> (A/AAAA of the mail server), imap., smtp., autoconfig., autodiscover. (CNAME to mail.<domain>) and SRV for _imaps, _submission, _submissions, _pop3s, _autodiscover, all through the DNS module (cp/names.go). No central host name appears in a customer's client settings.
  • mail.domain.names.ensure (button "Set up mail apps" on the domain card; dry_run gives the plan) first asks ssl.cert.list for a valid certificate that already covers the names (a wildcard first), otherwise has one ordered. It attaches it for SNI to mail., imap. and smtp. on Postfix and Dovecot and to the set-up pages, then checks that 993 and 465 present it. mail.names.scan (every 30 min) finishes domains that are not ready (retry every 6 h) and rechecks ready ones daily.
  • Set-up pages are static files in the panel web server's new upstream mailcfg: Thunderbird autoconfig.<domain>/mail/config-v1.1.xml, Outlook autodiscover (POX XML and JSON v2). The .well-known/autoconfig on the customer's own website is not built (web module).
  • mail.client.profile: an Apple .mobileconfig for one mailbox, signed on the node with openssl cms using the domain's certificate when there is one, unsigned otherwise. It carries no password; the phone asks.
  • mail.client.config names mail.<domain> once that domain is ready, and the old server host name before.
  • MX stays on the server host on purpose (see the ADR): MTA-STS and DANE need a certificate for the MX name without SNI, and the PTR, HELO and MX must be one name.
  • CardDAV and CalDAV are served at the server host, and also at the shared mail host once it is ready (davHosts; davInfo and the Contacts tab name the shared host then). Apps set up with the server host keep working.

Ports

25 (STARTTLS), 465, 587, 993, 143 (STARTTLS), 995, 110 (STARTTLS), 4190 (ManageSieve). mail.tls.check asks each by SNI and the install self-test prints one line per port. While the server only has its self-signed certificate those lines fail on purpose.

Outgoing family (forward-confirmed reverse DNS)

The daily reverse-name check (mail.reputation.check) tells which public addresses have a PTR equal to the HELO name that points back. decideOutbound then narrows outgoing mail: if only IPv4 passes, Postfix's smtp client gets inet_protocols = ipv4, if only IPv6 passes, ipv6; with several addresses of one family smtp_bind_address(6) is the one that passes. If nothing passes nothing is narrowed (mail must still leave; the findings say what to fix). Receiving and every other service keep both families. The Reputation tab shows the choice and the audit entry is mail.outbound.chosen. An administrator's own inet_protocols in main.cf wins.

Screens (ui/)

Mail page: tab "Spam and held mail". Domain card: "Mail apps" (components/mail-apps.tsx). Server page: Protection tab (spam switches, levels, Rspamd stats, Spamhaus note), Server tab (POP3 switch), Reputation (outgoing family). components/spam.tsx, spam-server.tsx.

Traps

  • Greylisting is on: the first test message from a new sender may be answered 451. Test with a second try, or switch it off. A test from a private address (a lab, a LAN) is never greylisted: Rspamd counts it as local (local_addrs).
  • Changed Rspamd worker sockets need a restart, not a reload (the module does that).
  • Rspamd marks Spamhaus as blocked behind public resolvers; that is not a failure of the filter.
  • Dovecot 2.4 has its own translation in distro_dovecot.go; both 2.3 and 2.4 configs are checked with doveconf and sievec.

Importing keys and mail (card C, w12)

mail.dkim.import {domain, selector, key_file|private_key, activate?, ignore_dns?, replace?}: puts an existing RSA key (PKCS#1/8) in place as a file on the mail node (agent op mail.dkim.install, 0640 root:_rspamd), never in the database, the job log or a result. The public half is compared with the TXT at selector._domainkey.domain (match / mismatch / not_published / unknown). A key that differs from DNS is stored pending instead of signing, unless ignore_dns; an active key it replaces is retired for 7 days. mail.maildir.import {mailbox, source} (administrators, a job): copies a Maildir from a path on the node into an existing mailbox (agent op mail.maildir.import): folders (.A.B), flags, file dates, maildirfolder, subscriptions kept; messages are matched by unique name, so a second run adds only what is new and widens flags (and moves a message read in the meantime from new to cur). One import per mailbox at a time; links are never followed; the quota is recalculated afterwards. {CRAM-MD5} hashes are kept by mail.mailbox.create (cp/import.go).

DNS hold (batch fix mail-dns-hold, 2026-10-27)

Moving our own mail to s1 stopped because adding the imported domains pushed MX, SPF (v=spf1 mx ~all), DMARC p=none, a new DKIM selector and the client names to Hostinger at once, and no preview said so.

  • mail.domain.add {dns: write|hold, dkim: new|import}. write (default) is the old behaviour. hold writes nothing anywhere and keeps the live MX, SPF and DMARC in mail_domains.dns_kept (DMARC's p= also goes to dmarc_policy). dkim import makes no key: the old server's key comes next with mail.dkim.import and keeps its selector.
  • While dns_hold is set, publishDNS returns the records with held: true and writes nothing, so every later writer (DKIM, DMARC, MTA-STS, the mail host switch, server rename) is covered; mail.names.repair and moves leave the zone alone too.
  • mail.dkim.import on a held domain: the imported key becomes the only key (the panel's own keys were never published and are removed from the server), so nothing in DNS changes for DKIM.
  • mail.domain.dns.fix {id, mx: keep|move} now has dry_run: every record, what it replaces in public DNS and where it is written ("at Hostinger", "in this panel's DNS", or by hand). Running it ends the hold. SPF is merged, never replaced (mergeSPF: the published record's entries and its all stay, this server's addresses are added); a kept MX and DMARC stay; mx move points the MX at this server. Kept values follow public DNS before every publish, so an old server removed from SPF at the provider is not put back.
  • mail.domain.dns.preview {domain, dns, dkim} (read-only) is the same list for a domain that has no mail here yet; the FastPanel importer shows it per domain.
  • Also: mail.hostname.ensure reuses an active certificate that covers the name (a wildcard first) before ordering one; in shared mode a covering certificate goes on the mail ports before the shared host is ready; the default shared host is mail.<a domain of this panel> taken from the panel's own names (web.panel_host.list), not the provider's ip-* host name.

One mail host for every domain (w12 mail-host)

Owner, 2026-10-27: "I want mine under mail.respiresoft.com for all domains". Card G1 gave every domain its own names; this is the server-wide choice.

  • Settings (node settings JSON, no migration): host_mode shared | per_domain ("" = per_domain, so existing servers do not move; mail.server.enable on a new node sets shared), shared_host (default mail.<registrable domain of the panel host>, else of the server's host name), and the state shared_ready, shared_error, shared_cert. Per domain: mail_domains.host_mode (migration 0019) "" follows the server | own (white label) | shared.
  • Actions. mail.host.get; mail.host.set (mode, shared_host; dry run lists every DNS and configuration change per domain, then one long job); mail.domain.host.set (the per-domain override, same shape); mail.host.resolve (internal: mail host and webmail host of a domain; the webmail asks). Event mail.hosts.changed makes the webmail follow.
  • Effective host per domain (mailhost.go: withHostMode fills transient fields on a copy of the domain; no lookups): sharedWant (intent), sharedOK (the host is ready), mxHost. Everything reads those: domainRecords (MX, MTA-STS record and policy mx:), clientRecords (SRV to the shared host; no mail./imap./smtp. records; _autodiscover._tcp points at autodiscover.<domain>), autoconfig./autodiscover. CNAMEs (cnameTarget), the set-up files, the Apple profile, mail.client.config, the repair of MX, the Mail apps card.
  • Readiness first. The MX and the mail-app names keep the server's own host name until sharedEnsure says the shared host is ready: it resolves to the mail server (the record is written through dns.record.set when the zone is on this panel), a certificate covers it (pickCert, wildcard first, else ssl.cert.issue target mail), it is attached to the mail ports once (ssl.cert.attach, so Postfix and Dovecot get one SNI entry), and ports 993 and 465 present it. mail.names.scan retries it every 30 minutes and republishes every domain when it turns ready. Overridden (own) domains keep their per-domain SNI.
  • Per domain in shared mode only autoconfig. and autodiscover. are needed: web vhosts through mailcfg, one certificate (target panel), no mail-port check.
  • Switching (hostApplyNode): save settings, sharedEnsure, per domain publishDNS + removal of the per-domain records this panel wrote (dns.record.unset, only when the value is still ours) + namesEnsure, one syncNode, event. Switching back republishes the per-domain records.
  • Deliverability. The reputation list gets shared_host_ok or shared_host (what is missing, with a Check now action). Domain DNS checks follow the effective MX.
  • Trap. PTR, HELO and DANE stay on the server's host name. If the shared host is not the server's own name, senders without SNI see the server's certificate; the plan says so. modules/dns/cp/zones.go still writes mail.<zone> as MX in its "mail" template (card C); the mail module's records win when published.

Batch fix (mail-hosts, 2026-10-27)

  • The blocker: web.panel_host.ensure refused upstream: mailcfg because the web module's params schema listed only panel, dav and mtasts (the handler knew it). The schema now has it; modules/web/cp/upstream_schema_test.go keeps the enum and loopbackUpstreams in step.
  • Certificates, reuse first, everywhere: certFor (names.go) lists the active certificates of the node and takes one that covers every name (a wildcard first, at least 14 days left) before ordering; attachCert attaches only what is missing. The shared host, each domain's names and contacts and calendar use it, so on s1 *.respiresoft.com serves mail.respiresoft.com without a new order (test with s1's real certificate list).
  • A domain whose mail. name is the shared host (respiresoft.com under mail.respiresoft.com) or the server's own name keeps that A record and its web page when it switches to shared (keepMailName); before, the switch would have removed the shared host's own address.
  • mail.domain.names.ensure fails its job with the reason when the names are not ready (it said "Finished without problems").
  • Errors shown to people drop the machine code (shortErr); a zone hosted elsewhere is said in words.
  • Previews: one plan line per domain ("DNS of x: 6 records added, 3 removed") with the records inside; "Add mail" lists one record per line.
  • Self-test: the stored result keeps when it ran and the POP3 state; mail.server.get drops the POP3 port lines and says it is out of date when POP3 changed since (freshSelftest). Agent check names are shown in words (checkWords); the shared host's finding has its own line, not "Reverse name (PTR)".
  • Not done here: an old per-domain certificate stays attached to the mail ports after a switch to shared (the ssl module has no detach; harmless SNI entries, renewed until removed by hand). DANE (TLSA) is published for the server's host name only: in shared mode with another name, senders find no TLSA at the MX and fall back to MTA-STS.

Connect a phone (ux/mail-scan-to-connect)

mail.connect.create (permission mail.mailbox.password, medium, dry run) makes a link https://<webmail host>/connect/<token> for one mailbox, shown as a QR code and as text in the mailbox's App passwords section and in the webmail (Settings, Devices). The token is 32 random bytes; only its SHA-256 is kept (mail_connect_tokens); it lives 10 minutes, works once, and a newer link replaces an unused older one. At most 10 links per mailbox per hour and 8 phones (app password slots). mail.connect.peek and mail.connect.redeem are for the webmail module only: peek changes nothing (so link previews cannot spend it), redeem spends the token in one UPDATE, makes an app password named after the device (phone link as creator) and returns it once with mail.client.config's server names and ports (IMAP 993 SSL, SMTP 465 SSL, so every domain's own or shared mail host is right). If the app password cannot be made, the token is given back. Creation and use are audited (mail.connect.create, mail.connect.redeem); the token never is. The phones are the mailbox's app passwords, listed and revoked in the same place as the others.

New-mail source for push notifications (webmail push)

Dovecot tells the panel when mail arrives, so a person is told about new mail with no webmail tab open (the other half is in webmail/docs.md; the push itself is core.push.send, docs/web-push.md).

  • Dovecot side. The push-notification plugin with the Lua driver (dovecot-core 2.4 ships it; older versions need dovecot-lua). Two files, rendered by the module and written by mail.files.apply like every other managed file (kind dovecot_push, names conf and lua, root:dovecot 0640): /etc/dovecot/rc-push.conf (settings, pulled in by an !include_try at the end of dovecot.conf; the agent writes the 2.4 form on 2.4 nodes) and /etc/dovecot/rc-push.lua (the script, which holds the URL and the secret). It runs in lmtp only: every MessageNew, in whatever folder LMTP or Sieve filed it (the OX driver was tried and rejected: it reports INBOX only and needs per-mailbox metadata). Each delivery becomes one PUT with {user, event, folder, from, subject, uid}. No body, no attachment. A slow panel cannot hold a delivery: 2 s connect, 5 s request, no retry (a lost notification is acceptable, a stuck delivery is not).
  • Only where it can work. The files are rendered when the mail node is the control node and the panel listens on plain http://127.0.0.1:<port> (RC_PANEL_URL, default http://127.0.0.1:7080). On a mail server that is another machine, or a panel on https only, the module renders both files empty, which removes them. The agent also writes nothing when Dovecot has no Lua driver. The normal reconcile (mail.reconcile, any apply) adds, changes or removes them; a dry run shows them.
  • Panel side. PUT|POST /api/v1/hooks/mail/arrived (internal/api/hooks.go) answers on loopback only: a request from another address, or one a reverse proxy forwarded (X-Forwarded-For and friends), is refused with 403, and no credentials is a 401. The basic-auth password is a shared secret the module makes on first use (24 random bytes, in the module's vault as new-mail-push/<node>, never printed, not in dovecot.conf). The route hands it to the internal action mail.push.arrived, which compares it in constant time, ignores events other than messageNew and any delivery to Junk, Spam, Trash, Drafts, Sent or the quarantine, ignores addresses that are not enabled mailboxes, and publishes mail.message.arrived {address, folder, from, subject, uid, account_id} to the account owner only. The webmail module subscribes.
  • Selftest. mail.server.selftest adds, only where the files are in place: "new-mail push configured" (Dovecot's own doveconf -n names the script), "new-mail push script" (it carries the panel address) and "new-mail push route" (the route is called with no credentials and must answer 401). Rotating the secret: delete the vault entry and apply again.
  • Tried live on s1's Dovecot 2.4.2 in a private test instance (not the live mail server): INBOX and Sieve fileinto deliveries both post, with the folder name; quoting and non-ASCII subjects survive.

Mail checks and stronger DKIM keys (1.0.15)

  • Every DNS lookup of a record name asks for the full name with its final dot, so the server's search domain can never turn a missing mta-sts.<domain> into a wrong "now" value. mail.domain.dns.check reads each domain's own name servers (internal/dnsauth); the score on the Mail page uses that check.
  • A signing key under 2048 bits (keys moved from an old server) shows "Make a stronger key": it publishes a 2048-bit key under a new selector next to the old one. "Switch to key" is refused until the provider serves the new record; the old selector stays published 7 days.
  • "Fix it" publishes the mail-app names too (autoconfig, autodiscover, SRV). It never changes an MX unless mx is move: the MX the domain has today is kept.