Email sender domain setup: SPF, DKIM and DMARC explained
What each record does, what Gmail requires of bulk senders, the order to set them up in, and the mistakes that break delivery.
The short answer
Three DNS records prove that mail claiming to come from your domain is really yours. SPF lists the servers allowed to send for the domain. DKIM adds a cryptographic signature to each message that receivers check against a public key you publish. DMARC tells receivers what to do when a message fails both checks and sends you reports. Gmail's published rules, in force from 1 February 2024, ask every sender to set up SPF or DKIM, and ask anyone who sends more than 5,000 messages a day to Gmail accounts to set up SPF, DKIM and DMARC, align the From domain with the SPF or DKIM domain, and support one-click unsubscribe in marketing mail.
For an online store the practical order is: set up the platform's own domain authentication for each tool that sends in your name (marketing platform, shop, helpdesk, transactional service), publish one SPF record that covers them, enable DKIM for each, and add DMARC at the monitoring policy first. The records are DNS entries, so the work is configuration and testing; check whether your DNS host or email tools charge for any part of it. For the platform side see our guides to moving between email platforms and email marketing pricing units.
What each record does
| Record | Where it lives | What it does | A fact worth knowing |
|---|---|---|---|
| SPF | A TXT record on the domain, starting v=spf1 | Lists who may send for the domain | At most 10 DNS-lookup terms (include, a, mx, ptr, exists, redirect); only one SPF record per name |
| DKIM | A TXT record at selector._domainkey.yourdomain | Publishes the public key that verifies message signatures | The signature covers the From header and a body hash; keys of 1024 bits or longer, 2048 recommended by Gmail |
| DMARC | A TXT record at _dmarc.yourdomain | Sets the policy for failures and the report address | Policy p= is none, quarantine or reject; rua= receives aggregate reports |
Two details cause most trouble. SPF allows at most ten DNS-lookup terms during evaluation (the standard counts include, a, mx, ptr and exists mechanisms and the redirect modifier, not ip4, ip6 or all); exceeding the limit produces a permanent error, so adding one "include" for every tool you try eventually breaks the record. And a domain must not publish more than one SPF record: the standard says multiple SPF records are not permitted for the same owner name, so a second tool's instructions must be merged into the existing record, not added as another.
Sources: [2]
SPF: who may send
| Ending | Result | What the standard says |
|---|---|---|
| -all | fail | An explicit statement that the sender is not authorized to use the domain |
| ~all | softfail | A weak statement that the host is probably not authorized; receivers should not reject on this result alone |
| ?all | neutral | The domain explicitly asserts nothing about whether the address is authorized |
| +all | pass for everyone | The all mechanism always matches, so +all authorizes every sender; this is our reading of the standard, not a sentence in it |
Sources: [2]
DKIM: signing every message
A sender signs each message with a private key and publishes the matching public key in DNS at the name selector._domainkey.yourdomain, as a TXT record whose p= tag holds the key; an empty p= means the key has been revoked. The d= tag names the signing domain and the s= tag the selector, which lets a domain keep several keys at once, for example one per sending tool. The signature covers the From header, the other headers listed in h= and a hash of the body. RFC 6376 requires keys of at least 1024 bits for long-lived keys, and Gmail's help page says keys must be 1024 bits or longer and recommends 2048. In practice each sending platform gives you the selector and the record value to publish; you do not generate the signature yourself.
DMARC: policy, reports and alignment
| Tag | Values | What it means |
|---|---|---|
| p= | none, quarantine, reject | none asks for no action; quarantine asks receivers to treat failing mail as suspicious; reject asks them to reject it |
| rua= | mailto address | Where aggregate reports are sent; without it receivers must not generate them |
| sp= | same values as p | Policy for subdomains only; if absent, p applies to subdomains |
| pct= | 0 to 100, default 100 | Share of the mail stream the policy applies to |
| adkim= and aspf= | r (relaxed) or s (strict), default relaxed | How closely the signing or SPF domain must match the From domain |
Sources: [3]
DMARC passes when SPF or DKIM passes and the passing domain aligns with the domain in the visible From address. Under relaxed alignment the organizational domains must match; under strict alignment only an exact domain match counts. That is why a marketing tool that sends from its own domain but shows your address in From still fails DMARC unless it signs with your domain or uses an aligned return path. Gmail's page says the DMARC policy for bulk senders can be set to none, so a monitoring policy meets that requirement; moving to quarantine or reject later is your decision once the reports show every legitimate sender passes.
What Gmail requires
| Applies to | Requirement |
|---|---|
| All senders: authentication | Set up SPF or DKIM for sending domains; DKIM keys 1024 bits or longer, 2048 recommended |
| All senders: infrastructure | Valid forward and reverse DNS for sending IPs; use a TLS connection; follow RFC 5322 message format |
| All senders: conduct | Keep the spam rate below 0.3% in Postmaster Tools; do not impersonate Gmail From headers |
| More than 5,000 messages a day to Gmail accounts | Set up SPF and DKIM; set up DMARC (the policy can be none); align the From domain with the SPF or DKIM domain |
| Marketing and subscribed messages from those senders | Support one-click unsubscribe and include a clearly visible unsubscribe link in the body |
| Monitoring | A stricter target of a spam rate below 0.10%, and avoid reaching 0.30% or higher |
Sources: [1]
The page states a threshold of more than 5,000 messages a day to Gmail accounts and does not say that smaller senders may skip authentication: the all-senders list already asks for SPF or DKIM. It gives no timeframe for honouring an unsubscribe request, so we do not state one. Other mailbox providers publish their own rules, which we did not read.
Sources: [1]
A sensible order of work
| Step | What to do | How to check |
|---|---|---|
| 1 List senders | Marketing platform, shop, helpdesk, transactional service, invoicing, anything that sends in your name | One written list |
| 2 SPF | Publish one v=spf1 record that includes each sender, ending -all or ~all | Count lookup terms; confirm only one SPF record exists |
| 3 DKIM | Enable DKIM in each platform and publish the selector record it gives you | Each platform shows the domain as verified; send a test and read the headers |
| 4 DMARC | Publish _dmarc with p=none and a rua address | Reports arrive and list every legitimate sender as passing |
| 5 Alignment | Make each sender sign with your domain or use an aligned return path | Test messages pass DMARC alignment in the headers |
| 6 Tighten | Move p to quarantine, then reject, when reports are clean | Watch reports for a failed legitimate sender after each change |
Editorial opinion
Common mistakes
| Mistake | Why it breaks | Fix |
|---|---|---|
| Two SPF records | The standard does not allow multiple SPF records for one name | Merge them into one record |
| More than 10 lookup terms | Evaluation fails with a permanent error | Remove unused includes or use fewer senders |
| SPF with +all | It authorizes every sender | Use -all or ~all |
| DKIM key under 1024 bits | Below the minimum the standard and Gmail ask for | Use 2048 bits where the platform allows |
| DMARC without a reachable rua address | No reports, so you cannot see failures | Publish a monitored rua address |
| Tool sends with its own domain in the signature | DMARC alignment fails | Use the tool's custom-domain authentication |
| Jumping straight to p=reject | A legitimate sender you forgot is rejected | Start at none and read the reports |
Editorial opinion
Frequently asked questions
- What are SPF, DKIM and DMARC?
SPF lists the servers allowed to send for your domain, DKIM signs each message so receivers can verify it against a public key in your DNS, and DMARC tells receivers what to do when a message fails both and where to send reports.
- Do I need all three?
Gmail's help page asks every sender to set up SPF or DKIM, and senders of more than 5,000 messages a day to Gmail accounts to set up SPF, DKIM and DMARC, with the From domain aligned to the SPF or DKIM domain. Setting up all three is the safe course.
- What DMARC policy should I start with?
Gmail's page says the DMARC policy for bulk senders can be set to none. Starting at none with a report address lets you see every sender before you move to quarantine or reject.
- Why does my SPF record fail with many tools?
SPF allows at most ten DNS-lookup terms and only one SPF record per name, so each added include uses part of the budget and a second record is not allowed; merge the senders into one record.
- Do transactional emails need unsubscribe links?
Gmail's page states the one-click unsubscribe requirement for marketing and subscribed messages and does not extend it to transactional mail; your platforms and local law may differ, so check them.
Sources and checks
Sources
Nikita Latyshev is the founder of LATYNEX Labs, an independent publication about business software and infrastructure. LATYNEX Labs is published by Latynex Trade OÜ, Estonia. How the site checks facts, handles sponsorship and earns money is described on its methodology, editorial policy and affiliate disclosure pages.