SPF, DKIM & DMARC — Email Authentication Guide

Your SMTP test passes but mail still lands in spam? That is a domain authentication problem, not a server problem. Here is how to fix it properly with three DNS records.

There are two separate questions in email: can I send? and will it be trusted? An SMTP test answers the first. SPF, DKIM and DMARC answer the second.

SMTP was designed in an era of mutual trust and does nothing to verify that a sender is who they claim to be — anyone can write any address into MAIL FROM. These three DNS records are the layer added on top to close that gap, and since 2024 both Google and Yahoo require them from anyone sending at volume.

SPFWho may send
DKIMProof of origin
DMARCWhat to do on failure

SPF — Sender Policy Framework

SPF is a DNS TXT record naming every server allowed to send mail for your domain. When a message arrives, the receiver checks the connecting IP against that list.

Type:  TXT
Host:  @            (your root domain)
Value: v=spf1 include:_spf.google.com include:sendgrid.net ~all

Reading it left to right:

  • v=spf1 — the version. Always first.
  • include:_spf.google.com — authorise Google Workspace's servers.
  • include:sendgrid.net — authorise SendGrid as well.
  • ~all — soft-fail anything else. Use -all for a hard fail once you are confident the list is complete.

Two rules people break constantly. First, you may publish only one SPF record per domain — a second one causes a permanent error. Second, SPF evaluation is capped at ten DNS lookups; each include: counts, and exceeding it invalidates the whole record.

DKIM — DomainKeys Identified Mail

DKIM signs each outgoing message with a private key. The receiver fetches your public key from DNS and verifies the signature, proving the message came from your domain and was not modified in transit.

You do not generate DKIM keys by hand — your provider does it. Google Workspace, Microsoft 365, SendGrid, Mailgun, Amazon SES and Zoho all have a one-click option that gives you a record to publish:

Type:  TXT
Host:  selector1._domainkey
Value: v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQ...

The selector (selector1 above) lets you run several keys at once, which is how you rotate keys or add a second sending platform without downtime. Each provider uses its own selector name.

DKIM's key advantage over SPF is that it survives forwarding. When a message is forwarded, the connecting IP changes and SPF breaks — but the DKIM signature travels with the message and still validates.

DMARC — the policy layer

DMARC ties the other two together. It tells receivers what to do with mail that fails both checks, and asks them to send you reports about it.

Type:  TXT
Host:  _dmarc
Value: v=DMARC1; p=none; rua=mailto:[email protected]; pct=100; adkim=r; aspf=r
TagMeaning
p=Policy: none (monitor), quarantine (spam folder) or reject (refuse outright).
rua=Where to send aggregate XML reports. Essential — this is how you discover who sends as your domain.
pct=Percentage of failing mail the policy applies to. Useful for a gradual rollout.
adkim= / aspf=Alignment strictness: r relaxed (subdomains count) or s strict (exact match).

Roll it out in three stages

  1. Monitor — publish p=none with a rua address. Nothing changes for your mail; reports start arriving within a day or two.
  2. Quarantine — after two to four weeks of clean reports, move to p=quarantine, optionally starting at pct=25.
  3. Reject — once quarantine causes no complaints, move to p=reject. Only now is your domain genuinely protected from spoofing.

Do not start at p=reject. Almost every organisation has forgotten senders — a billing system, a CRM, an old contact form — that will stop delivering silently. The monitoring phase exists precisely to find them.

Beyond the three records

Authentication is necessary but not sufficient. These also carry real weight:

  • Reverse DNS (PTR) — the sending IP should resolve back to a hostname that matches its HELO name. Missing rDNS is an instant penalty at most large receivers.
  • Blocklist status — check the sending IP against Spamhaus, SpamCop and Barracuda. A listing overrides perfect authentication.
  • Dedicated vs shared IPs — on shared relay IPs you inherit other customers' reputation. Dedicated IPs need warming over several weeks.
  • List hygiene — repeatedly sending to dead addresses produces bounces and spam-trap hits, which damage reputation faster than almost anything else.
  • One-click unsubscribe — Google and Yahoo now require the List-Unsubscribe header on bulk mail.
  • Complaint rate — keep spam complaints below 0.3%. Above that, filtering tightens sharply.

How to verify it all works

Check the DNS records resolve:

dig TXT yourdomain.com +short                      # SPF
dig TXT selector1._domainkey.yourdomain.com +short # DKIM
dig TXT _dmarc.yourdomain.com +short               # DMARC

Then send a real message to a mailbox you control and inspect the raw headers. In Gmail, open the message, choose Show original, and look for:

Authentication-Results: mx.google.com;
       dkim=pass [email protected];
       spf=pass smtp.mailfrom=yourdomain.com;
       dmarc=pass (p=NONE) header.from=yourdomain.com

Three passes means you are done. Use the SMTP test tool to send that message, and the error code reference if the send itself fails first.

Frequently asked questions

If SMTP delivery succeeds but mail lands in spam, the cause is almost always missing or misconfigured domain authentication. Publish an SPF record listing your sending servers, enable DKIM signing, and add a DMARC policy. Then check that the sending IP has matching reverse DNS and is not on a public blocklist. Content matters far less than authentication.

SPF (Sender Policy Framework) is a DNS TXT record listing which servers are permitted to send mail for your domain. A receiving server compares the connecting IP against that list. A typical record looks like v=spf1 include:_spf.google.com ~all. You may publish only one SPF record per domain.

DKIM (DomainKeys Identified Mail) adds a cryptographic signature to the headers of every outgoing message. The receiving server fetches your public key from DNS and verifies the signature, proving the message genuinely came from your domain and was not altered in transit. Unlike SPF, DKIM survives forwarding.

DMARC ties SPF and DKIM together and tells receivers what to do when a message fails both. Start with p=none to collect reports without affecting delivery. Once reports confirm your legitimate mail passes, move to p=quarantine, then p=reject. Jumping straight to reject will silently kill legitimate mail you have forgotten about.

Typically between a few minutes and a few hours, governed by the TTL on the record. Lower the TTL to 300 seconds a day before making changes if you need them to propagate quickly. Verify with dig TXT yourdomain.com rather than guessing.

No. Publishing two SPF records is a configuration error and causes a permerror, which most receivers treat as a failure. Merge every sending source into a single record using multiple include: mechanisms, and keep the total under the ten-DNS-lookup limit.

The SMTP checker tests the transport: connectivity, encryption, authentication and message acceptance. SPF, DKIM and DMARC are evaluated by the receiving server after acceptance. Send a test message to a mailbox you control and inspect the received headers — they will show spf=pass, dkim=pass and dmarc=pass when everything is configured correctly.