Email DNS Authentication: SPF, DKIM, DMARC, MTA-STS
Receivers decide whether to trust your mail from a handful of DNS records. This page explains what each record proves, how to publish it, and how to check it. It applies whether you run your own server, rent mailboxes, or send app mail through a provider.
What each record does
Section titled “What each record does”| Record | Where | Proves or controls |
|---|---|---|
| MX | example.org | Which hosts receive mail for the domain |
| A / AAAA | smtp.example.org | The mail host’s IP. DNS-only, never proxied. |
| PTR (reverse DNS) | Set by your IP provider | That the IP belongs to the name your server announces |
| SPF | TXT at the envelope-sender domain | Which IPs may send mail with that domain in the SMTP MAIL FROM |
| DKIM | TXT at <selector>._domainkey.example.org | That a signed message came from the domain in the signature’s d= tag, unaltered |
| DMARC | TXT at _dmarc.example.org | What receivers should do when neither SPF nor DKIM passes aligned with the visible From, and where to send reports |
| MTA-STS | TXT at _mta-sts plus an HTTPS policy file | That senders must use verified TLS to reach your MX |
| TLS-RPT | TXT at _smtp._tls | Where senders report TLS failures to your MX |
| CAA | example.org | Which certificate authorities may issue for the domain |
| DNSSEC / DANE | At the registrar / _25._tcp.<mx> TLSA | Signed DNS answers; pinning your MX certificate in DNS |
MX, A and PTR
Section titled “MX, A and PTR”- MX points at a hostname, and the hostname has an A record. An MX that points at an IP address violates RFC 5321, and receivers treat it as broken.
- Mail hostnames must be DNS-only. Cloudflare’s proxy carries HTTP only, so
an orange-cloud A record for
smtporimapbreaks mail at once. A proxied record answers with Cloudflare addresses (104.21.*,172.67.*). - PTR and the SMTP greeting must agree. The name your server sends in its
banner and
EHLOshould resolve to the server’s IP, and that IP’s PTR should point back to the name. Only your IP provider can set the PTR. If you can’t get one, relay outbound mail through a smarthost; see Running Your Own Email.
dig +short MX example.orgdig +short A smtp.example.org # must be your server's IP, not a proxy addressdig +short -x 203.0.113.25 # PTR: should return smtp.example.org.SPF authorizes the IPs that may use a domain in the SMTP envelope sender
(MAIL FROM, which becomes the Return-Path). It does not check the From
address people see.
example.org. TXT "v=spf1 mx include:spf.brevo.com ~all"-
Publish exactly one SPF record per name. Two records make SPF return a permanent error.
-
Stay under 10 DNS lookups. Each
include,a,mx,existsandredirectcounts, including the ones nested inside a provider’s include. -
Use the provider’s customer include, and check that it lists IPs. Look at what an include resolves to before you publish it:
Terminal window dig +short TXT spf.brevo.com # Brevo's sending rangesdig +short TXT _spf.brevo.com # "v=spf1 -all": authorizes nothingdig +short TXT sendinblue.com # Brevo's own corporate SPF: also lets in Google, Zendesk and IntercomAn include for the wrong name either authorizes nothing (and you lose the SPF fallback without noticing) or authorizes far more than you meant.
-
Remove includes for services you’ve stopped using, such as Cloudflare Email Routing’s
_spf.mx.cloudflare.netafter you move the MX away. -
With a smarthost, the relay’s SPF is usually the one checked. Relays such as Brevo send with their own bounce domain in
MAIL FROM, so receivers check the relay’s SPF, not yours, and your SPF doesn’t align with yourFrom. That’s normal: DMARC passes on DKIM. Keep your SPF correct anyway, for direct deliveries and for receivers that check it. -
~all(soft fail) is the common choice for a domain that is still being tidied up.-all(hard fail) suits domains whose senders you fully control.
DKIM signs each message with a private key; receivers fetch the public key from
<selector>._domainkey.<domain>.
- Use 2048-bit keys. Replace any 1024-bit key.
- Each sender gets its own selector. Your server’s key (for example
dkim._domainkey) and each provider’s keys (Brevo issuesbrevo1andbrevo2CNAMEs, and Cloudflare Email Sending adds its own selector) live side by side. - Provider DKIM is often a CNAME. Never proxy it. A proxied CNAME returns Cloudflare A records instead of the provider’s TXT key, so every signature fails.
- Delete selectors for providers you’ve left. A dangling CNAME to a provider that no longer serves the key does no good, and stale records make audits harder.
dig +short TXT dkim._domainkey.example.orgdig +short TXT brevo1._domainkey.example.org # follows the CNAME to the keyDMARC ties SPF and DKIM to the From address people see.
_dmarc.example.org. TXT "v=DMARC1; p=quarantine; rua=mailto:dmarc-reports@example.org"-
A message passes DMARC when at least one of SPF or DKIM passes and is aligned with the
Fromdomain. Under relaxed alignment (the default),mail.example.orgaligns withexample.org; strict alignment (adkim=s,aspf=s) needs an exact match. -
Move the policy up gradually:
p=nonewhile you read reports and fix every legitimate sender, thenp=quarantine, thenp=reject. Send-only subdomains whose only sender you control can go straight top=rejectonce their mail passes. -
pctis gone. RFC 9989 (May 2026), the current DMARC standard, removed thepcttag. Uset=yto signal that a policy is in testing; don’t plan a rollout around percentages. -
sp=sets the policy for subdomains that have no DMARC record of their own. -
Reports need a real mailbox.
ruaaddresses receive daily aggregate reports (XML, usually compressed). Create the mailbox or alias, then confirm that a report arrives within a few days. Silence from an address that doesn’t exist looks exactly like silence from a domain with no problems. -
Reports sent to another domain need authorization. If
example.org’s reports go toreports@example.net, thenexample.netmust publish:example.org._report._dmarc.example.net. TXT "v=DMARC1" -
Parse reports with a tool rather than by eye; see Email Deliverability.
Domains that don’t send mail
Section titled “Domains that don’t send mail”Lock down every domain that will never send or receive mail, including parked domains. Spoofers target them because nobody watches them.
example.net. MX 0 .example.net. TXT "v=spf1 -all"_dmarc.example.net. TXT "v=DMARC1; p=reject; adkim=s; aspf=s"The null MX (0 ., RFC 7505) tells senders the domain accepts no mail, so mail
to it bounces at once instead of retrying for days. A domain with no MX at all
falls back to its A record, which for a proxied website means mail to it hangs.
Remove all three records before the domain starts using mail.
MTA-STS and TLS-RPT
Section titled “MTA-STS and TLS-RPT”Without MTA-STS, a sender that can’t start TLS with your MX quietly delivers in plaintext. MTA-STS (RFC 8461) tells senders to require a valid certificate.
-
Serve a policy file at
https://mta-sts.example.org/.well-known/mta-sts.txtwith a valid certificate andContent-Type: text/plain:version: STSv1mode: testingmx: smtp.example.orgmax_age: 86400A small Cloudflare Worker is a convenient host for it. Every
mx:line must match a real MX name. -
Publish the TXT record, and change its
idevery time the policy changes:_mta-sts.example.org. TXT "v=STSv1; id=20261020T0000" -
Publish TLS-RPT (RFC 8460) so senders tell you about failures:
_smtp._tls.example.org. TXT "v=TLSRPTv1; rua=mailto:tls-reports@example.org" -
Stay in
mode: testinguntil TLS reports come back clean and certificate expiry is monitored. Inenforcemode an expired certificate on your MX stops inbound mail from MTA-STS senders.
DNSSEC and DANE
Section titled “DNSSEC and DANE”- DNSSEC signs your DNS answers. Turn it on at your registrar when it supports it (Cloudflare Registrar does it in one step).
- DANE (RFC 7672) publishes a TLSA record such as
_25._tcp.smtp.example.orgso DNSSEC-validating senders can pin your MX certificate. It needs DNSSEC, and a common TLSA form (3 1 1) pins the key. If your ACME client generates a new key on renewal, publish the next key’s TLSA before you renew, or reuse the key; otherwise a routine renewal breaks inbound mail from DANE senders. Treat DANE as optional until you’ve automated that.
Verify
Section titled “Verify”# What receivers seedig +short TXT example.org | grep spf1dig +short TXT _dmarc.example.orgdig +short TXT _mta-sts.example.orgcurl -s https://mta-sts.example.org/.well-known/mta-sts.txt
# Your MX's certificate, as a sender sees it (outbound port 25 is often blocked# on home connections; run it from a server)openssl s_client -starttls smtp -connect smtp.example.org:25 -servername smtp.example.org </dev/null \ | openssl x509 -noout -subject -enddateThen send a message from each sending path to a mailbox you control at a large
provider and read the Authentication-Results header. You want spf=pass or
dkim=pass with a matching domain, and dmarc=pass. Repeat for every path:
people’s mail, aliases, app mail and server alerts.
Example: self-hosted mailboxes with a smarthost
Section titled “Example: self-hosted mailboxes with a smarthost”A domain whose server receives mail and sends everything through Brevo:
example.org. MX 10 smtp.example.org.smtp.example.org. A 203.0.113.25 ; DNS-onlyexample.org. TXT "v=spf1 mx include:spf.brevo.com ~all"dkim._domainkey.example.org. TXT "v=DKIM1; k=rsa; p=…" ; your server's keybrevo1._domainkey.example.org. CNAME (value issued in your Brevo account)brevo2._domainkey.example.org. CNAME (value issued in your Brevo account)example.org. TXT "brevo-code:…" ; Brevo domain verification_dmarc.example.org. TXT "v=DMARC1; p=quarantine; rua=mailto:dmarc-reports@example.org"_mta-sts.example.org. TXT "v=STSv1; id=20261020T0000"_smtp._tls.example.org. TXT "v=TLSRPTv1; rua=mailto:dmarc-reports@example.org"example.org. CAA 0 issue "letsencrypt.org"Copy Brevo’s values from your account; don’t build them from an example. App
mail from a subdomain (mail.example.org) gets its own records from the
provider; see App and Transactional Email.
Mistakes that fail silently
Section titled “Mistakes that fail silently”| Mistake | What happens | How to catch it |
|---|---|---|
| An SPF include for the wrong name | SPF authorizes nothing, or far too much | dig every include and read what it returns |
| A second SPF or DMARC record | Permanent error; receivers ignore both | Count the records at each name |
| A proxied DKIM CNAME | Every signature from that provider fails | dig TXT the selector; an A answer means proxied |
| An MX pointing at an IP, or at a proxied name | Mail bounces or hangs | dig MX, then dig A on the answer |
A DMARC rua with no mailbox | No reports, so problems stay invisible | Confirm a report arrives |
| Leftover records for old providers | Stale trust; confusing audits | Review DKIM selectors and includes after every migration |
MTA-STS in enforce without certificate monitoring | One expired certificate stops inbound mail | Monitor the certificate your MX actually serves |
| A parked domain with no records | Spoofable, and mail to it hangs | Publish null MX, SPF -all and DMARC p=reject |
Related
Section titled “Related”- Running Your Own Email
- Self-Hosted Mail Server: mailcow
- Self-Hosted SimpleLogin
- App and Transactional Email
- Email Deliverability
- Cloudflare