MTMalte Therkildsen Lab PostkontorP43 · Mail domains

Inside

The parts of Postkontor that do not need DNS: the reader for zone files, which turns what a DNS provider exports into records and writes the fixes back; the merge that puts the platform into a domain’s own SPF record without taking anything away; the ownership token; and the lifecycle a domain moves through.

Zone file

RFC 1035’s format: $ORIGIN and $TTL, @ and names relative to the origin, a blank name that repeats the one above, comments, strings in quotes and parentheses that run over lines. A line the reader cannot read is reported with its number, and the lines around it are kept.

LineNameTTLTypeValue

Written back

zone

SPF merge

A domain that already sends mail elsewhere has an SPF record, and a second one makes both fail. The merge puts the platform’s include into the record that is there: before all or redirect, keeping every sender and the record’s own all.

Mechanisms, separated by spaces.

txt
    TermQualifierCounts a lookup

    Ownership token

    HMAC-SHA-256 over the account and the domain with the platform’s key, the first 160 bits written in base32. The same account and domain always give the same token; another account gives another.

    zone

    Lifecycle

    The states a domain moves through and what moves it. An event that does not apply in a state leaves the domain where it is.

    StateWhat moves it on
    Waiting for proofThe ownership record is found: provisioning. 14 days without it: released.
    ProvisioningThe mail server has the domain and its keys: waiting for records.
    Waiting for recordsA check finds every required record right at both resolvers: active.
    Active2 checks in a row find a required record wrong: degraded.
    DegradedOne check finds them right again: active.
    SuspendedThe payment resumes: back to where it was, and an active domain is checked again.
    ReleasedNothing. Another account proving the domain releases it from any state.
    How Postkontor is built
    1. Postkontor is the DNS side of a mail platform, written for this prototype from its specification: what a customer’s domain must publish so the platform can take its mail, how the platform proves the domain is the customer’s, and how it checks the records until they are right. Nothing here uses a DNS library.
    2. Ownership is a TXT record at _postkontor.<domain> holding a token: HMAC-SHA-256 over the account and the domain with a key only the platform has, the first 160 bits in base32. A token made for another account is recognised and refused. A domain that is not proved in 14 days is released.
    3. The platform asks for 9 kinds of record: MX, SPF and two DKIM keys (RSA and Ed25519) are required, and DMARC, MTA-STS, TLS reports, the SRV records that let mail apps find the servers, autoconfig and CAA are recommended. Each expected record is looked up at Cloudflare and at Google, and judged at each: right, missing, wrong, or in conflict, when something there would take mail or trust from the platform, such as a second MX at another provider or a second SPF record.
    4. A record that is right at one resolver and not yet at the other is propagating. A wildcard is found by asking for a random name first; a name that only the wildcard answers is reported as absent, even though it seems to resolve.
    5. The fixes are written so nothing the domain has is lost: the platform’s include goes into the SPF record that is there, before its all or redirect, and its all keeps its qualifier; a DMARC policy the domain already has is kept. The fixes are shown as a zone file, which the zone file reader can read back.
    6. The health score weighs the purposes, counts a propagating one at three quarters and a weak one at half, and a required purpose that fails holds the score at 64 or less. The problems are listed in the order to fix them.
    7. The lifecycle is a state machine: waiting for proof, provisioning, waiting for records, active. 2 failed checks in a row make an active domain degraded, and one good check makes it active again. A stopped payment suspends it.
    8. The three domains on the first page are made up, under .example, with addresses from the documentation ranges, and their DNS is simulated by two tables: a change reaches Cloudflare’s at once and Google’s at the next check.
    9. The audit asks real DNS through the Lab’s worker, which passes only a domain name and a record type from a short list to Cloudflare’s and Google’s DNS over HTTPS, and fetches an MTA-STS policy from https://mta-sts.<domain>/ without following a redirect and only up to 64 KB. Nothing is stored or logged.
    10. The audit reads the MX hosts and names the provider, walks the SPF record through every include and counts its lookups against the limit of 10, tries 34 common DKIM selectors and reads each key’s type and size, reads DMARC, MTA-STS and checks the policy covers every MX host, TLS reports, CAA and BIMI, checks that each mail host’s address names it back, and asks 3 blocklists about the first address.
    11. check_host is RFC 7208’s: the mechanisms in order, include and redirect followed, macros expanded, a lookup limit of 10 and a limit of 2 lookups that find nothing.
    12. What it does not do: it sends no mail and runs no SMTP, so it cannot see whether the mail server really offers TLS or signs with the keys it publishes; DKIM selectors are guessed, so a key under an unusual selector is not found; DNSSEC is not checked.