SPF, DKIM and DMARC Explained: How to Set Up Email Authentication and Stay Out of Spam

If your emails land in spam, or Gmail rejects them, email authentication is usually the first thing to check. Here is how SPF, DKIM and DMARC work and how to set them up correctly.

Order confirmations in spam. Newsletters rejected by Gmail. Phishing emails sent in your company’s name. All three problems have the same first fix: email authentication with SPF, DKIM and DMARC.

Since 2024, large mailbox providers such as Gmail and Yahoo require authentication from bulk senders, and other providers have followed. If you send marketing or transactional email, this is no longer optional.

This guide explains each record in plain language and shows how to set them up.

The three records in one table

Record What it does Analogy
SPF Lists which servers may send email for your domain Guest list at the door
DKIM Adds a digital signature proving the email was not changed and comes from your domain Wax seal on a letter
DMARC Tells receivers what to do when SPF/DKIM fail, and sends you reports House rules plus a security camera

SPF (Sender Policy Framework)

SPF is a TXT record on your domain listing the services allowed to send email for it.

Example:

example.com.  TXT  "v=spf1 include:_spf.google.com include:sendgrid.net -all"
  • include: adds the servers of a service (your email provider, newsletter tool, helpdesk, shop platform)
  • -all means: reject everything else. ~all (soft fail) is more forgiving during setup

Important rules:

  • Only one SPF record per domain. Two records break SPF
  • SPF allows a maximum of 10 DNS lookups. Every include counts, and includes inside includes count too. Too many tools can push you over the limit
  • List every service that sends as your domain: Google Workspace or Microsoft 365, newsletter tool, webshop, invoicing software, helpdesk, CRM

DKIM (DomainKeys Identified Mail)

DKIM signs every outgoing email with a private key. The public key is published in DNS so receivers can verify the signature.

Each sending service gives you a DKIM record to add, usually as a TXT or CNAME record with a selector:

google._domainkey.example.com.   TXT   "v=DKIM1; k=rsa; p=MIIBIjANBgkq..."
s1._domainkey.example.com.       CNAME s1.domainkey.u12345.wl.sendgrid.net.

Set up DKIM for every service that sends email as your domain, not just your main mailbox. Use 2048-bit keys where the provider supports them.

DMARC (Domain-based Message Authentication, Reporting and Conformance)

DMARC connects SPF and DKIM to the domain in the From address that people see. A message passes DMARC when SPF or DKIM passes and is aligned with the From domain.

Example record:

_dmarc.example.com.  TXT  "v=DMARC1; p=none; rua=mailto:[email protected]; adkim=r; aspf=r"
  • p=none monitor only, no action
  • p=quarantine failing mail goes to spam
  • p=reject failing mail is rejected
  • rua= where aggregate reports are sent

Step-by-step setup

  1. List all services that send email from your domain. Check invoices, marketing tools, the webshop, CRM, support tools, and ask every team
  2. Create or fix SPF with all of them, within the 10-lookup limit
  3. Enable DKIM in each service and add the DNS records it gives you
  4. Add DMARC with p=none and a reporting address
  5. Read the reports for a few weeks. A DMARC report tool turns the XML reports into readable dashboards
  6. Fix unknown or failing sources: a forgotten tool, a forwarding service, a misconfigured server
  7. Move to p=quarantine, optionally with pct= to apply it to part of the mail first
  8. Move to p=reject when legitimate mail passes consistently

Going straight to p=reject without monitoring is the most common way to block your own invoices or order emails.

Gmail and Yahoo bulk sender requirements

Since February 2024, Gmail and Yahoo require bulk senders (Google defines this as sending around 5,000 or more messages a day to Gmail addresses) to:

  • Authenticate with SPF and DKIM
  • Publish a DMARC policy (at least p=none) with alignment between the From domain and SPF or DKIM
  • Offer one-click unsubscribe in marketing emails and process unsubscribes quickly
  • Keep spam complaint rates low (Google mentions staying below 0.3%, and ideally much lower)

Microsoft announced similar requirements for high-volume senders to Outlook.com addresses in 2025. Even if you send less, following these rules improves deliverability everywhere.

Common mistakes

  • Two SPF records on the same domain
  • Too many DNS lookups in SPF
  • A tool sending without DKIM on your domain, failing DMARC alignment
  • Sending from the root domain for everything: consider a subdomain for marketing (for example news.example.com) so marketing reputation does not affect transactional mail
  • p=reject too early
  • Forgetting parked domains: domains that send no email should have v=spf1 -all and a p=reject DMARC record to prevent spoofing

How to check your setup

  • Send a test email to a Gmail account and use “Show original” to see SPF, DKIM and DMARC results
  • Use an online SPF/DMARC checker or dig:
dig +short TXT example.com
dig +short TXT _dmarc.example.com
dig +short TXT google._domainkey.example.com
  • Check Google Postmaster Tools for spam rate and authentication data if you send larger volumes

Frequently asked questions

Do I need DMARC if I only send a few emails?

Yes. It protects your domain from being spoofed in phishing emails, and more mailbox providers expect it.

Will DMARC p=reject block my own emails?

Only if some legitimate services are not authenticated. That is why you monitor with p=none first.

Does authentication guarantee inbox placement?

No. It is the foundation. Content, engagement, list hygiene and complaint rates still matter (see Klaviyo vs Mailchimp vs Brevo and 10 email flows).

Need help with email deliverability?

I set up SPF, DKIM and DMARC, clean up sending sources and fix deliverability problems for stores and businesses. See my marketing automation service or request help.