SPF, DKIM, and DMARC: A Practical Setup and Troubleshooting Guide

Set up email authentication for your domain in the right order, avoid the SPF lookup limit and other common mistakes, and move DMARC from monitoring to enforcement safely.

Published by SpeedTesting.dev · Updated · 4 min read

Quick answer

Publish one SPF record, enable DKIM signing with every service that sends as your domain, start DMARC at p=none with reports, and only tighten the policy once the reports show all legitimate mail passing.

Why Email Authentication Matters Now

Email was designed without any way to prove who sent a message. SPF, DKIM, and DMARC add that proof using DNS records the domain owner publishes. Without them, anyone can send mail that claims to be from your domain, and receiving servers have little reason to trust your legitimate mail.

Since 2024, Google and Yahoo have required bulk senders (those sending more than about 5,000 messages a day to their users) to authenticate with SPF and DKIM, publish a DMARC policy, and keep spam complaint rates low. Smaller senders are held to a lighter version of the same rules. In practice, any domain that sends email, even a handful of invoices a day, should have all three in place.

You can check each record as you go with our SPF checker, DKIM checker, and DMARC checker.

Step 1: List Everything That Sends Email as Your Domain

Most authentication problems come from a sender nobody remembered. Before publishing anything, make a list:

  • Your mailbox provider (for example Google Workspace or Microsoft 365).
  • Newsletter and marketing platforms.
  • Transactional email services used by your website or app (password resets, receipts).
  • Help desk, CRM, invoicing, and booking systems.
  • Website contact forms and any server that sends mail directly.

Each of these will need to be covered by SPF, by DKIM signing, or ideally both.

Step 2: Publish One Correct SPF Record

SPF is a TXT record at the root of your domain listing the servers allowed to send mail using your domain in the envelope sender (the technical "Return-Path" address). A typical record looks like: v=spf1 include:_spf.google.com include:sendgrid.net ~all

Rules that prevent most SPF failures:

  • Publish exactly one record starting with v=spf1. Two separate SPF records cause a permanent error, and both are ignored.
  • Stay within 10 DNS lookups. Every include, a, mx, redirect, and exists mechanism counts, including those nested inside providers' includes. Exceeding the limit causes a permanent error. Our SPF checker counts them for you.
  • Remove services you no longer use. Old includes waste lookups.
  • End with ~all (soft fail) while you are setting up; move to -all only when you are confident the list is complete. With DMARC in place, ~all is generally sufficient.

SPF has a structural weakness: it breaks when mail is forwarded, because the forwarding server is not in your list. That is why DKIM matters.

Step 3: Turn On DKIM Signing Everywhere

DKIM adds a cryptographic signature to each message. The sending service signs with a private key, and you publish the matching public key in DNS at a name like selector._domainkey.example.com. Because the signature travels inside the message, it usually survives forwarding.

Enable DKIM in the admin panel of every service on your list. Each one will give you a selector name and either a TXT record containing the key or a CNAME pointing to a key it manages. Once published, verify each selector with the DKIM checker.

Use 2048-bit keys where the provider offers them. If a TXT key is too long for your DNS host's input field, most hosts split it into multiple quoted strings automatically; do not paste it with line breaks.

Step 4: Add DMARC in Monitoring Mode

DMARC ties the other two to the address people actually see in the From line. A message passes DMARC if SPF or DKIM passes and the domain that passed aligns with the visible From domain. The DMARC record also tells receivers what to do with mail that fails and where to send reports.

Start with a monitoring policy, published as a TXT record at _dmarc.example.com:

v=DMARC1; p=none; rua=mailto:[email protected]

With p=none, nothing is blocked, but receivers send daily aggregate reports listing every IP address that sent mail claiming to be your domain and whether it passed. These XML reports are hard to read raw; a free or paid DMARC report service will summarise them.

Check your published record with the DMARC checker.

Step 5: Move to Enforcement Safely

Read reports for two to four weeks. For each legitimate sender that fails, fix its SPF or DKIM. Unknown sources sending as your domain are either forgotten services or spoofing.

When all legitimate mail passes, tighten the policy gradually:

  • p=quarantine; pct=25 sends a quarter of failing mail to spam.
  • Increase pct to 100 over a few weeks while watching reports.
  • p=reject tells receivers to refuse failing mail outright, which is the strongest protection against spoofing of your domain.

If your domain never sends email at all, publish v=spf1 -all and a DMARC record with p=reject immediately. Parked domains are a favourite target for spoofing because owners rarely notice.

Troubleshooting Failures

When a message fails, open its full headers (often "Show original" or "View source") and find the Authentication-Results line. It states the SPF, DKIM, and DMARC result and which domains were evaluated.

  • SPF fail or softfail: the sending IP is not in your record. Add the service's include or check that the Return-Path uses your domain.
  • SPF permerror: usually two SPF records or more than 10 lookups.
  • DKIM fail: the selector is not published, the key in DNS does not match, or the message was modified in transit, often by a mailing list adding a footer.
  • DMARC fail with SPF and DKIM passing: an alignment problem. The service is authenticating its own domain, not yours. Set up a custom return-path or custom DKIM domain in that service.

For delivery problems unrelated to authentication, such as a sending server listed on a spam blocklist, see our guide on why an IP address gets blacklisted.

Related Articles

Useful tools