Skip to content

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.

RecordWhereProves or controls
MXexample.orgWhich hosts receive mail for the domain
A / AAAAsmtp.example.orgThe mail host’s IP. DNS-only, never proxied.
PTR (reverse DNS)Set by your IP providerThat the IP belongs to the name your server announces
SPFTXT at the envelope-sender domainWhich IPs may send mail with that domain in the SMTP MAIL FROM
DKIMTXT at <selector>._domainkey.example.orgThat a signed message came from the domain in the signature’s d= tag, unaltered
DMARCTXT at _dmarc.example.orgWhat receivers should do when neither SPF nor DKIM passes aligned with the visible From, and where to send reports
MTA-STSTXT at _mta-sts plus an HTTPS policy fileThat senders must use verified TLS to reach your MX
TLS-RPTTXT at _smtp._tlsWhere senders report TLS failures to your MX
CAAexample.orgWhich certificate authorities may issue for the domain
DNSSEC / DANEAt the registrar / _25._tcp.<mx> TLSASigned DNS answers; pinning your MX certificate in DNS
  • 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 smtp or imap breaks 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 EHLO should 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.
Terminal window
dig +short MX example.org
dig +short A smtp.example.org # must be your server's IP, not a proxy address
dig +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, exists and redirect counts, 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 ranges
    dig +short TXT _spf.brevo.com # "v=spf1 -all": authorizes nothing
    dig +short TXT sendinblue.com # Brevo's own corporate SPF: also lets in Google, Zendesk and Intercom

    An 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.net after 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 your From. 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 issues brevo1 and brevo2 CNAMEs, 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.
Terminal window
dig +short TXT dkim._domainkey.example.org
dig +short TXT brevo1._domainkey.example.org # follows the CNAME to the key

DMARC 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 From domain. Under relaxed alignment (the default), mail.example.org aligns with example.org; strict alignment (adkim=s, aspf=s) needs an exact match.

  • Move the policy up gradually: p=none while you read reports and fix every legitimate sender, then p=quarantine, then p=reject. Send-only subdomains whose only sender you control can go straight to p=reject once their mail passes.

  • pct is gone. RFC 9989 (May 2026), the current DMARC standard, removed the pct tag. Use t=y to 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. rua addresses 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 to reports@example.net, then example.net must publish:

    example.org._report._dmarc.example.net. TXT "v=DMARC1"
  • Parse reports with a tool rather than by eye; see Email Deliverability.

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.

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.

  1. Serve a policy file at https://mta-sts.example.org/.well-known/mta-sts.txt with a valid certificate and Content-Type: text/plain:

    version: STSv1
    mode: testing
    mx: smtp.example.org
    max_age: 86400

    A small Cloudflare Worker is a convenient host for it. Every mx: line must match a real MX name.

  2. Publish the TXT record, and change its id every time the policy changes:

    _mta-sts.example.org. TXT "v=STSv1; id=20261020T0000"
  3. Publish TLS-RPT (RFC 8460) so senders tell you about failures:

    _smtp._tls.example.org. TXT "v=TLSRPTv1; rua=mailto:tls-reports@example.org"
  4. Stay in mode: testing until TLS reports come back clean and certificate expiry is monitored. In enforce mode an expired certificate on your MX stops inbound mail from MTA-STS senders.

  • 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.org so 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.
Terminal window
# What receivers see
dig +short TXT example.org | grep spf1
dig +short TXT _dmarc.example.org
dig +short TXT _mta-sts.example.org
curl -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 -enddate

Then 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-only
example.org. TXT "v=spf1 mx include:spf.brevo.com ~all"
dkim._domainkey.example.org. TXT "v=DKIM1; k=rsa; p=…" ; your server's key
brevo1._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.

MistakeWhat happensHow to catch it
An SPF include for the wrong nameSPF authorizes nothing, or far too muchdig every include and read what it returns
A second SPF or DMARC recordPermanent error; receivers ignore bothCount the records at each name
A proxied DKIM CNAMEEvery signature from that provider failsdig TXT the selector; an A answer means proxied
An MX pointing at an IP, or at a proxied nameMail bounces or hangsdig MX, then dig A on the answer
A DMARC rua with no mailboxNo reports, so problems stay invisibleConfirm a report arrives
Leftover records for old providersStale trust; confusing auditsReview DKIM selectors and includes after every migration
MTA-STS in enforce without certificate monitoringOne expired certificate stops inbound mailMonitor the certificate your MX actually serves
A parked domain with no recordsSpoofable, and mail to it hangsPublish null MX, SPF -all and DMARC p=reject

Recent changes

  1. docs(wiki): reorganize the email guides for self-hosters gitayam