Applies to: SimpleTwo 0.9.x, mail 0.72 · Checked: 08.10.2026
SimpleTwo mail is two roles. mail holds the mailboxes, the queue and the database; clients connect to it. mx is the edge: it takes mail from the internet, sends mail out, signs it with DKIM and checks what arrives. The mx nodes keep no database and no mailboxes, only a queue on their own disk. Between the two are LMTP (on mail) and port 2525 (on mx), closed to anyone but each other.
Until DNS has an MX record pointing at an mx node, no mail reaches you from the internet — and
that is right until somebody is named to answer abuse reports (the abuse@ and postmaster@
addresses). Make them aliases in identity for real people before you publish the MX record.
0. Deployment
What you need first
| What | Why |
|---|---|
the postgres role or an external cluster | the mail cluster's own database; the coordinator creates it |
object storage — the s3 role or Settings → External stores | message bodies and attachments, the simpletwo-mail bucket. Without storage the mail role does not start: the agent refuses to deploy it |
the identity role | people, their addresses, aliases and groups, app passwords |
a public name for mail | clients reach mail over JMAP on 443 of this name |
a public name, a public address of its own and a PTR for each mx | the MX target, the EHLO name and the certificate's name |
The mail host is 2 vCPU / 8 GB; the disk is needed in storage rather than on the host: about
1.9 GB per person a year before attachment deduplication. More in sizing.
Order
- Storage, postgres and identity are already up.
- Servers & deploys → Add a host, role
mail: Private address (the leg toward postgres, storage andmx) and Public DNS name, e.g.mail.s2.<domain>. The name must point at the host's public address or at the organisation's address whose NAT forwards 443 here. The service obtains its own certificate on 443. - The
mxrole — two hosts in different failure domains, each with a Private address and a Public DNS name, e.g.mx1.s2.<domain>andmx2.s2.<domain>. With a name and a certificatemxoffers STARTTLS on 25 and opens app-password submission on 587 and 465; without a name only 25 works, without TLS, and the Mail DNS card warnsno_mx_name. - Publish the DNS records (section 1), the service addresses before the MX record.
When clients see mail
The Mail tab appears in clients on the mail_url field of the discovery document
(/.well-known/simpletwo.json). Once a minute the coordinator opens
https://<mail public name>/healthz and announces mail_url (with mail_domains) only when it is
the mail service that answers. Once it stops answering, mail_url is withdrawn after 15 minutes and
the tab hides. Mail can also be switched off for the whole installation: Settings → Product
options, the mail row (with the access mode beside it — direct, or VPN only).
curl -fsS https://mail.s2.<domain>/healthz
curl -fsS https://s2.<domain>/.well-known/simpletwo.json # look for mail_url
How people use mail — mail for the user. Clients reach it with the same sign-in as
chat; third-party programs need an app password: sending is SMTP on
587/465 of the mx nodes, reading is JMAP only. There is no IMAP or POP3.
1. Domains, DNS records and DKIM keys
Domains belong to organisations and are kept in the directory: Console → Settings → Organizations and domains — a block per organisation with its domains, the products switched on per domain.
- Mail: whether mail accepts mail for the domain, and how: mailboxes (the domain's
addresses are mailboxes, aliases and groups; a person's primary address may only be in such a
domain of their organisation), aliases only (the domain receives for aliases of mailboxes
in another), and for the time of a move relays to the old server (section 18). Each
organisation has one primary domain: its mail's
postmaster@is there, and a person made without an address getslogin@primary domain. - Sign-in: whether people may sign in with an address in the domain, and who checks the password (the directory or an identity provider).
A domain that still holds addresses cannot be removed, and mail cannot be switched off on one primary addresses are in; the primary is changed only by naming another. Mail takes the list from the directory itself (within half a minute) and keeps a copy for when the directory is away. The Holds column says how many mailboxes, aliases and groups a domain has.
Console → Mail → Mail DNS shows each mail domain's records — MX, SPF, DMARC, DKIM, SRV, MTA-STS and TLS-RPT — and checks each one in DNS.
| Record | Name | The value the card expects |
|---|---|---|
| MX | <domain> | 10 <mx name>. — one record per mx node, equal priority |
| TXT (SPF) | <domain> | v=spf1 mx -all |
| TXT (DMARC) | _dmarc.<domain> | v=DMARC1; p=quarantine; rua=mailto:dmarc@<domain> |
| TXT (DKIM) | <selector>._domainkey.<domain> | the public key; selectors look like s2e<date> (ed25519) and s2r<date> (RSA), both records are needed |
| SRV | _submission._tcp.<domain>, _submissions._tcp.<domain> | 0 1 587 <mx name>. and 0 1 465 <mx name>. |
| SRV | _jmap._tcp.<domain> | 0 1 443 <mail name>. |
| TXT, CNAME, TXT | _mta-sts.<domain>, mta-sts.<domain>, _smtp._tls.<domain> | see section 7 |
The PTR of each mx public address is set by whoever owns the address (the provider): it must
point at the node's name. Without a PTR large mail services refuse your mail or file it as spam.
The coordinator makes the DKIM keys: an ed25519 and an RSA 2048 pair per domain. Changing a key takes three steps:
- New DKIM key makes a new pair; publish its two records.
- Activate the new key is available only once the new records answer in DNS.
- The old pair is retired; its records may go seven days later, on the date the card shows.
Two mx nodes
There are two mx nodes by design, in different failure domains: on different hosts and, where
possible, in different racks or sites. Each has its own public address, a PTR record and its own
MX record, both with the same preference: senders spread mail between the nodes and, when one
fails, go to the other. SPF mx covers both. rspamd's greylisting needs a Redis the two share.
While there is one node, the Mail DNS card warns: when it is lost, mail from the internet waits
at the senders and outgoing mail waits in the queue. Every thirty seconds the mail cluster checks
that the nodes answer and shows it in /healthz (mx.mx_reachable), with a warning when none does.
From mail 0.73 a connection is not closed after its message: the next message to the same place
goes on it — from the mail cluster to an mx node, from mx to the recipient's server or the relay,
and from mx back into the cluster. A connection waits 30 seconds for the next message, carries at
most 20 and serves at most 5 minutes; at most 4 wait for one server, and 32 in all. A message that
needs stronger protection (an enforce MTA-STS policy at the recipient) never goes on a
connection opened without it. The counters are in the mail cluster's and the mx node's
/healthz (sessions): connections opened, messages sent on one already open, and why
connections were closed.
Service addresses
Every mail domain must take mail at postmaster@ (RFC 5321 requires it), abuse@ (complaints
about mail from you), and dmarc@ and tls-reports@, where the domain's DNS records ask others to
send their reports. Console → Mail → Service addresses shows whether they exist and makes the
missing ones with a button: identity groups that cannot be deleted by accident and that anyone may
write to. The administrator who pressed it is the first member; add the people who will answer in
Users → Groups. An address a mailbox or an alias already holds is left as it is.
2. Mail connectors: devices without a password and the provider's relay
Mail that passes mx another way than usual is set up with connectors in Console → Mail → Mail connectors. A connector is an object of the directory with a name of its own, as Exchange's Send and Receive Connectors are; each has the mx nodes it works on ticked. A new connector is on every node until unticked. A node takes a change within a minute.
A receive connector is for printers, an ERP or a monitoring system that cannot sign in: the networks they connect to mx port 25 from, the addresses they may write as (in the installation's mail domains), and where to (inside the organisation only, or anywhere). One network belongs to one connector. Everything else signs in with an app password on ports 587/465; why such a device cannot send is in the Message trace (section 9).
A send connector is the provider's relay, when the provider blocks outbound port 25:
host:port (several, separated by commas, are tried in turn); mx hands it all outbound mail,
DKIM-signed. When the relay asks for a sign-in, set a user name and a password: mx signs in with
AUTH PLAIN, and only after STARTTLS with a certificate valid for the relay's name. The password is
kept as the connector's secret in the directory and is not shown in the console again. With no
send connector a node delivers to each recipient's MX directly; a node has one send connector at
most.
3. Content filters
The filters are set in Console → Mail → Edge protection: a row per filter, in the order they check — a name, the protocol (milter or ICAP), the address, what a filter that does not answer means, what a virus means, the anti-virus's find headers and a timeout. The filters are the organisation's own services: mx runs neither rspamd nor an anti-virus itself. Every mx node takes the list on its next poll and restarts with it. The console holds the list to the same rules mx does and saves nothing mx would refuse.
On an mx node installed without the agent the same list is the MX_FILTERS variable, or the
file MX_FILTERS_FILE names (which is how the agent hands it over: a systemd environment does
not carry regular expressions with a \ intact) — a JSON list in the order they check:
[
{"name": "rspamd", "transport": "milter", "address": "inet:127.0.0.1:11332", "on_error": "open"},
{"name": "av", "transport": "icap", "address": "icap://av.corp.example:1344/respmod", "on_error": "closed"}
]
- milter — rspamd, clamav-milter, spamass-milter. A message the filter marks as spam
(
X-Spam: Yesand the like, thespam_signalfield) goes to Junk; the filter's fields are in the message's delivery headers, and the message's bytes are never changed. - icap — an anti-virus over RFC 3507. How the product says it found something is the
verdictfield (headers,header_patterns,on_modified_body,status_codes). on_error— what a filter that does not answer means:openlets the message through without it (the anti-spam default),closedtells the sender 451 to try again later (for an anti-virus).on_virus— an anti-virus's find:quarantine(ICAP's default) orreject.
A list that does not parse stops the service: a filter configured and quietly not run is mail
nobody checked. Greylisting is rspamd's greylist module with a Redis shared by every mx node;
mx keeps no greylist of its own.
4. DNS block lists
Every client of port 25 is checked against the block lists (default zen.spamhaus.org). A
listed client is told 554 5.7.1 … blocked using <zone> at every MAIL. Addresses in the allow
lists are not checked. The lists are set in Edge protection — zones separated by commas,
zone=127.0.0.2|127.0.0.4 to count only those answers, off for none — beside port 25's
connection bounds (total and per address, 0 for none). Without the agent: MX_DNSBL_ZONES,
MX_DNSWL_ZONES, MX_MAX_CONNECTIONS, MX_MAX_CONNECTIONS_PER_IP.
From mail 0.76 the same card has the submission ports' own connection bounds, 587 and 465: total
and per address, the two ports counted together and apart from port 25. There are none by
default: empty or 0 is no bound, and the submission ports take any number of connections. A bound
per address counts everyone behind one NAT as one client (and an IPv6 network by its /64): when an
office's scanners and programs send through one public address, they all share it, so set it no
lower than how many of them send at once. An mx node that sees IPv4 clients through a NAT64/SIIT
gateway (addresses 64:ff9b::…) puts them all in one /64, sharing one bound per address. The mail
devices' networks are not counted. A
connection over a bound is told 421 4.7.0 on 587 and closed on 465, and each such refusal is a
row of the submission refusal log (step connect, section 9). How many connections are open
now is on the mx node's /healthz (submission_connections) — a good guide to the number.
Without the agent: MX_SUBMISSION_MAX_CONNECTIONS, MX_SUBMISSION_MAX_CONNECTIONS_PER_IP.
Trusted ARC sealers
The provider's relay for outbound mail is a send connector (section 2).
Trusted ARC sealers: mx verifies every incoming message's ARC chain and writes the result
(arc=) into Authentication-Results. A chain decides anything only when its sealer is trusted
(a domain, with its subdomains — a mailing service you know, say): a message whose DMARC failed
is delivered when its chain passes and that sealer found DMARC passing. The list is empty by
default, and then chains are only recorded.
Each zone tests itself at start and hourly. A zone that stops answering as it should is
disabled, and the mx node's /healthz says why. The usual cause is a query through a public
resolver, which Spamhaus refuses: the node's resolver must be its own. Commercial use of Spamhaus
needs a DQS key.
5. The quarantine
A message in which the anti-virus found a virus, and one a filter quarantined, is held on the server. The sender is told it was accepted. Each recipient gets a notice from the postmaster: who sent it, the subject, the date, the reason, and the number to give the administrator.
Console → Mail → Quarantine lists the held messages. Only an administrator releases one to
its recipients or deletes it, and each action goes into the audit log with the administrator's
name. What nobody decides on is deleted after 30 days (MAIL_QUARANTINE_DAYS).
6. Groups with members outside
When a group has outside addresses (partners), each gets a copy of its own. The copy's
reverse-path is the group's service address, sales+bounce.<token>@corp.example, so an outside
recipient's refusal comes back to the group, not to whoever wrote to it.
- A bounce is logged on the copy's path in the delivery log and kept in the mailbox named for the
group's bounces. With none named, or while that mailbox is archived or belongs to a person who
has left (until it is made shared), it goes to
postmaster@the group's domain: its mailbox or, whenpostmaster@is a group (as the Service addresses card makes it), the group's members. Bounces never go to members outside. - The mailbox is named in Console → Mail → Group members outside → Bounces go to: any address
of a person's mailbox, a shared one or a room's, not a group's, an archived mailbox's or the
mailbox of a person who has left. An empty field gives the bounces back to
postmaster@. The change is in the audit log. From mail 0.72. - Never passed outside: delivery notices, messages judged spam, held messages, and all of a group's mail when the installation has no mx node.
- After five bounces in a row (each within a week of the last) a member outside is disabled: its copies stop and the log says why. An administrator can enable it again. From mail 0.72 whoever gets the group's bounces also gets a letter when a member is disabled: which group, which member, how many bounces in a row and how to enable it again — one letter per disabling.
- When a sender signs with SPF alone and its domain has
p=reject, a recipient outside may refuse the copy. That is a known limit of mailing lists.
7. MTA-STS
When a recipient's domain publishes an MTA-STS policy in enforce mode, mx sends it mail only to
the servers the policy lists, only over TLS, and only to a certificate valid for the server's
name. When that cannot be done, the message is not sent in the clear: it waits and is tried again.
The policies are kept on the mx node's disk; /healthz counts them.
Your own domain's policy is published by the coordinator. Mail DNS has three records for it:
_mta-sts.<domain>: a TXT record with the current policy's id. The id changes with the policy, and the record must then be updated.mta-sts.<domain>: a CNAME to the coordinator. The coordinator obtains the certificate for this name itself and serves the policy athttps://mta-sts.<domain>/.well-known/mta-sts.txt. The policy lists every mx node._smtp._tls.<domain>: a TXT record for TLS-RPT reports, sent totls-reports@<domain>. Make that address an alias for whoever reads the reports.
The policy's mode is chosen on the same card. Start with testing: senders report failures but
still deliver. Turn on enforce once a week of reports shows none. Under enforce a sender keeps
the policy for a week and sends only to the nodes it lists. It takes a new mx node once it sees
a new id in _mta-sts, so update that record as soon as you add a node.
The TLS-RPT reports you send
From mail 0.70 you send TLS-RPT reports (RFC 8460) too — to the domains that ask for them with
their _smtp._tls record. The mx node counts every connection to a receiver's mail server:
whether it negotiated TLS and, if not, why (no STARTTLS, a certificate expired, untrusted or for
another name, a server the receiver's MTA-STS policy does not list, a policy that could not be
fetched). Once a day, two hours after midnight UTC, the mail cluster sends each such domain the
past day's summary, from tls-reports@<first mail domain> and signed with your DKIM. The report
itself is delivered even when the receiver's TLS is broken, as RFC 8460 requires.
- Reports go only to
mailto:addresses, two per domain at most. Anhttps:address gets none: the mail cluster reaches the internet only through the mx node's SMTP; the list of reports says so. - Connections through the relay for outbound mail and to the old server during coexistence are not counted: they are not the receiver's mail servers.
- A connection that carried several messages in a row (from mail 0.73) is counted once.
MAIL_TLSRPT_REPORTS=offturns the sending off;MAIL_TLSRPT_ORGis the organisation's name in the reports (by default as in the DMARC reports).- The list of thirty days is Console → Mail → TLS reports sent; the counters are in the mail
cluster's
/healthz(tlsrpt_reports) and the mx node's (tlsrpt). - Upgrade the mail cluster first, then the mx nodes: an older cluster loses the sums a newer node sends it.
8. DMARC reports
The domains whose DMARC record asks for aggregate reports (rua) get them from you once a day:
how many messages in their name arrived, from which addresses, whether they passed SPF and DKIM,
and what was done with them. A UTC day's report goes out two hours after it ends, one per
domain. It is sent from dmarc@<the first mail domain>, the address your own DMARC record gives
for the others' reports; make it an alias for whoever reads them.
- Reports go only to
mailto:addresses, to two per domain at most. An address in another domain gets one only when that domain allows it with a_report._dmarcrecord (RFC 7489 §7.1). A report larger than an address's limit (!10m) is not sent to it. - SimpleTwo sends no failure reports (
ruf): they would carry the messages' content. MAIL_DMARC_REPORTS=offturns the reports off;MAIL_DMARC_ORGis the organisation's name in them (the first mail domain by default). Without an mx node no report is sent.- How many reports went and how many did not is in the mail cluster's
/healthz(dmarc_reports). The list of thirty days, with the addresses and why a report did not go, is Console → Mail → DMARC reports sent. - A message that failed DMARC but was delivered on a trusted sealer's ARC chain (see "The relay
for outbound mail, and trusted ARC sealers") is in the report with the reason
local_policy, and its comment names the chain: who sealed each instance and the address the message reached each from (RFC 8617 §7.2.2). From mail 0.70.