DNS and authentication

How to set up SPF, DKIM and DMARC

Short answer

SPF lists the servers allowed to send for your domain, DKIM signs each message with a key published in your DNS, and DMARC tells receivers what to do when neither passes for a domain matching your From address. Set them up in that order: one SPF record, DKIM for every service that sends as you, then DMARC at p=none with a report address. Move to quarantine or reject once reports show only legitimate mail.

Last checked 16 November 2026

SPF, DKIM and DMARC are three DNS records that let mail servers check that an email really comes from your domain. SPF says which servers may send for you, DKIM adds a cryptographic signature the receiver can verify, and DMARC ties both to the From address people see and tells receivers what to do when checks fail. Publish SPF and DKIM first, then DMARC.

Each has its own detailed guide: SPF record, DKIM setup and DMARC setup. This page is the overview.

Why you need all three

Mail has two sender addresses. The envelope sender (MAIL FROM, shown later as Return-Path) is used between servers and receives bounces. The From header is what the reader sees. SPF checks the first, DKIM checks whichever domain signed the message, and neither on its own checks the From address. DMARC closes that gap.

Mailbox providers now require them:

Provider All senders Bulk / high-volume senders
Gmail SPF or DKIM SPF and DKIM, DMARC (p=none allowed), alignment (Google)
Yahoo SPF or DKIM SPF and DKIM, DMARC at least p=none (Yahoo)
Outlook.com Not stated SPF and DKIM pass, DMARC at least p=none, from May 2025 (Microsoft)

How the three work together: one message, step by step

Say your app sends a receipt from receipts@acme.com through an email service that uses send.acme.com as the return-path. When it arrives at Gmail:

  1. SPF. Gmail looks up the SPF record for send.acme.com (the envelope domain) and checks that the connecting IP is listed. Pass.
  2. DKIM. Gmail reads the DKIM-Signature header, sees d=acme.com; s=s1, fetches the key at s1._domainkey.acme.com and verifies the signature. Pass.
  3. DMARC. Gmail fetches _dmarc.acme.com. The From domain is acme.com. DKIM passed for acme.com (exact match) and SPF passed for send.acme.com (same organizational domain, so it aligns under relaxed mode). Pass.

If either aligned check passes, DMARC passes. Having both gives you a backup: forwarding often breaks SPF, while DKIM usually survives it.

Step 1: list everything that sends as your domain

Before touching DNS, write down every service that sends mail with your domain in the From address: your mailbox provider, your app’s email API, your newsletter tool, CRM, helpdesk, billing system, website forms. Each one needs SPF coverage or a return-path of its own, and its own DKIM records.

Step 2: SPF

SPF is a single TXT record on the domain used in the envelope sender (RFC 7208):

acme.com.  TXT  "v=spf1 include:_spf.google.com ~all"

The rules that trip people up:

  • One record only. Two v=spf1 records cause a permerror.
  • 10 DNS lookups maximum. include, a, mx, ptr, exists and redirect all count, including nested ones (section 4.6.4).
  • End with ~all or -all. ~all is softfail, -all is fail.

Many email services avoid touching your main record at all by using their own return-path subdomain, such as send.acme.com, with its own SPF record. The SPF guide covers syntax and examples.

Step 3: DKIM

DKIM signs each message with a private key. The receiver fetches the public key from DNS at selector._domainkey.yourdomain and checks the signature (RFC 6376).

s1._domainkey.acme.com.  TXT  "v=DKIM1; k=rsa; p=MIIBIjANBgkq..."

Your email service generates the key and gives you the record, either as a TXT with the key or as a CNAME pointing to a key it hosts and rotates. Use 2048-bit keys where you can: RFC 8301 requires at least 1024 bits and recommends 2048. The DKIM guide covers selectors and key rotation.

Step 4: DMARC

DMARC is a TXT record at _dmarc.yourdomain (RFC 9989, which replaced RFC 7489 in May 2026):

_dmarc.acme.com.  TXT  "v=DMARC1; p=none; rua=mailto:dmarc@acme.com"

A message passes DMARC if SPF or DKIM passes and the passing domain aligns with the From domain. With the default relaxed alignment, send.acme.com aligns with acme.com; with strict alignment it does not.

Start at p=none to collect reports without affecting delivery. Read the aggregate reports for a few weeks, fix any legitimate source that fails, then move to p=quarantine and finally p=reject. The DMARC guide covers every tag.

Step 5: check your work

Query the records directly:

dig +short TXT acme.com
dig +short TXT s1._domainkey.acme.com
dig +short TXT _dmarc.acme.com

If a command prints nothing, the record is missing or still propagating. Then send a test message to a Gmail address, open it and choose Show original. You want SPF, DKIM and DMARC all to say PASS, with your domain next to DKIM.

Common setup mistakes

Symptom Cause Fix
spf=permerror Two SPF records or over 10 lookups Merge into one record, remove unused includes
dkim=pass but dmarc=fail DKIM signed with the vendor’s domain Add the vendor’s custom DKIM records
spf=pass but dmarc=fail Envelope sender is the vendor’s domain Set up a custom return-path on your subdomain
Record not found Host field entered as _dmarc.acme.com and the panel appended the domain again Enter _dmarc only

How Mailcandor handles it

When you add a domain, Mailcandor gives you three DKIM CNAME records plus an SPF record and bounce MX on send.yourdomain. That return-path is aligned with your domain under relaxed DMARC, and it does not touch your main SPF record. We also suggest a DMARC record. The DNS checks confirm each record is live, and our free tools check any domain’s SPF, DKIM and DMARC.

Questions

Do I need SPF, DKIM and DMARC?

Gmail and Yahoo require all senders to pass SPF or DKIM, and bulk senders (over 5,000 a day to Gmail) to have SPF, DKIM and DMARC. Outlook.com has the same rule for high-volume senders. Setting up all three is the safe default.

Which order should I set them up in?

SPF and DKIM first, for every service that sends as your domain. DMARC last, starting at p=none, because DMARC only passes when SPF or DKIM already passes and aligns.

What is DMARC alignment?

DMARC passes only if SPF or DKIM passes for a domain that matches the From address. In relaxed mode, the default, a subdomain counts as a match, so send.acme.com aligns with acme.com.

How long do the records take to work?

As soon as DNS serves them, which depends on the TTL. New records usually work within minutes to an hour. Changed records can take as long as the old TTL.

Can SPF pass and DMARC still fail?

Yes. SPF checks the envelope sender, which your email service may set to its own domain. If that domain does not match your From domain and DKIM is not signed with your domain either, DMARC fails.

Related

Send with someone on your side.

Unlimited domains on every plan, a person before any block, and 3,000 emails a month free. Tell us what you send and we set you up within one business day.