How-to

How to set up SPF, DKIM and DMARC for a sending domain

Last reviewed 18 September 2026

Set up authentication in this order: pick a subdomain to send from rather than your main domain, publish an SPF record listing your provider, publish the DKIM keys your provider issues, then publish DMARC at p=none with a reporting address. Read the aggregate reports for about two weeks, fix whatever is failing alignment, and only then move the policy to quarantine and finally to reject. Verify by sending yourself a message and reading its headers for three passes.

The three records do different jobs and they have to be in place in the right order, because DMARC is a policy about the other two and publishing a policy before the things it governs work is how people block their own mail. The whole job is four DNS records and about two weeks of waiting. The waiting is the part that cannot be skipped.

Choose a dedicated sending subdomain

Send from a subdomain, not from the domain you answer mail on. Something like send.example.com or mail.example.com, reserved for the mail your software sends, with example.com itself left for the messages you write to people by hand. The reason is recoverable damage. Reputation attaches to the domain that signs the mail, so a bad month on a sending subdomain can be retired and replaced in an afternoon, while the same month on your root domain follows your invoices, your password resets and your replies to customers, and cannot be replaced at all.

A subdomain also lets you separate kinds of mail later without starting over. One subdomain for course and campaign mail, another for transactional receipts, is the standard shape, and it means a complaint rate earned by marketing does not decide whether a receipt arrives.

Whatever you choose, write it down before you touch DNS, because the next three records all hang off it and a record published against the wrong host is the most common failure in this whole process.

Publish an SPF record for that subdomain

SPF, defined in RFC 7208, is one TXT record on the sending domain that names the servers allowed to send for it. In practice you do not list servers: your provider publishes an SPF domain of its own and you include it, which keeps working when they change infrastructure. One TXT record, one v=spf1 string, and no second SPF record on the same host, because two SPF records is a permanent error rather than a merge.

End the record with -all rather than ~all once you are sure the include list is complete. A hard fail tells receivers to reject mail from anywhere else; a soft fail tells them to accept it and note it. The soft version is the safer starting point and the worse resting place.

Remember that SPF is checked against the envelope sender, not the From line a reader sees, so this record alone proves nothing about your visible identity. That is what DMARC is for, three steps down.

The four records, with every provider-specific value written as a placeholder to replace
TypeHostValue
TXTsend.example.comv=spf1 include:[your provider’s SPF domain] -all
CNAME[selector]._domainkey.send.example.com[the DKIM target your provider gives you]
TXT_dmarc.send.example.comv=DMARC1; p=none; rua=mailto:[email protected]; adkim=s; aspf=s
TXT_dmarc.example.comv=DMARC1; p=none; rua=mailto:[email protected]
MXsend.example.com10 [your provider’s bounce host], if the provider asks for one

Publish the DKIM keys your provider issues

DKIM, defined in RFC 6376, signs the message with a private key your provider holds and publishes the matching public key in your DNS under a selector, which is just a label allowing more than one key to exist at once. Most providers hand you one or two CNAME records to add; some hand you a long TXT record containing the key itself. Either is fine. What matters is that the signature names your sending domain rather than the provider’s.

Check that specifically, because it is the difference between building your own reputation and renting a share of somebody else’s. In the headers of a signed message the signature carries a d= value; it should read d=send.example.com. If it reads the provider’s domain, the domain setup is not finished, however green the dashboard looks.

Add both selectors if you are given two. Providers rotate keys, and a rotation into a selector you never published fails silently on the day it happens.

Publish DMARC at p=none with a reporting address

DMARC, defined in RFC 7489, is a TXT record at _dmarc on the domain in your visible From line. It says that the From domain must align with a domain that passed SPF or DKIM, tells receivers what to do when nothing aligns, and asks them to send you aggregate reports. Publish it with p=none first. At p=none nothing is quarantined or rejected, so the record cannot break anything, and the reports start arriving immediately.

Put a real address in rua= and make sure somebody can read it. The reports are XML, one per receiver per day, and they are the only place you will learn that some fraction of your mail is failing alignment. Set adkim=s and aspf=s if you want strict alignment, meaning the exact domain rather than any subdomain; relaxed is the default and is usually enough while you are starting out.

Publish a record for the root domain as well as the sending subdomain, even if the root never sends. A domain with no DMARC record is a domain anyone can put in a From line, and the root is the one worth impersonating.

Read the reports for about two weeks before changing anything

Two weeks is the usual window and the reason is coverage rather than statistics: it takes that long for every system that sends mail under your name to have sent some. The list is always longer than expected. A helpdesk tool, an invoicing service, a form notifier, a calendar, a colleague’s client configured years ago, and a forwarding rule at a university that breaks SPF on every message it touches.

What you are looking for in the reports is mail that failed alignment and is yours, which is a configuration you have not finished, as against mail that failed and is not yours, which is either spoofing or a forwarder. The first kind has to be fixed before you tighten the policy. The second kind is the reason to tighten it.

Aggregate reports are readable by hand for a small sender, and there are free parsers if the volume gets annoying. Either way, read them rather than filing them. A policy moved to reject on top of an unread report is how a month of invoices stops arriving.

Move the policy to quarantine, then to reject

Once the reports show only mail you recognise passing and nothing of yours failing, change p=none to p=quarantine. Quarantined mail goes to the spam folder rather than being refused, so a mistake at this stage is visible and recoverable. Leave it there for a week or two and read the reports again.

Then move to p=reject, which is the point of the exercise: mail that claims your domain and cannot prove it is refused at the door. You can step there gradually with pct=, which applies the policy to a percentage of failing mail, though for a small sender the ramp buys less than it costs in confusion.

Nothing about the bulk sender rules requires reject. Google and Yahoo ask only that a DMARC record exist, and p=none satisfies that. Reject is what stops other people sending as you, which is a separate benefit worth the two weeks it takes to get there safely.

Verify with a test message and read its headers

Send a real message from your real sending setup to a mailbox at one of the large consumer providers, open the original message source, and read the Authentication-Results header. You are looking for three passes: spf=pass, dkim=pass, and dmarc=pass. Two out of three is the state most people ship in, and the missing one is almost always alignment.

Check the d= value in the DKIM-Signature header while you are there, and check the Return-Path, which is the domain SPF was actually evaluated against. If the Return-Path is your provider’s domain and DKIM signs yours, you will pass DMARC on the DKIM side and fail it on the SPF side, which is fine but worth knowing.

Then send to a second provider, because filtering decisions differ and one provider passing is not evidence of the other. Two mailboxes at two operators, once, is the whole test.

Record what you published, and re-check it twice a year

Write the four records into a file in your repository, with the date and the reason for each. DNS is the piece of infrastructure with no history, no diff and no review, usually edited in a web console at speed by whoever had the login, and a record nobody can explain is a record nobody will dare to change.

Put a reminder in for every six months. Keys get rotated, providers change their SPF include, a service gets added that sends under your name, and a DMARC report nobody reads is the only place any of that is visible. Ten minutes twice a year is the entire maintenance cost of authentication once it is working.

Common questions

Do I need all three of SPF, DKIM and DMARC?

Yes. Since February 2024 Google and Yahoo have required SPF and DKIM from every sender and a DMARC record from bulk senders, and unauthenticated mail is refused rather than filtered. The three do different jobs: SPF authorises servers, DKIM signs the message, and DMARC ties both to the From address a reader actually sees.

What DMARC policy should I start with?

p=none, with a working address in rua= so aggregate reports arrive. At p=none no mail is quarantined or rejected, so the record cannot break delivery, and the reports show you every system sending under your name. Move to quarantine once nothing of yours is failing alignment, then to reject.

Can I send from my main domain instead of a subdomain?

You can, and it is the choice you cannot undo cheaply. Reputation attaches to the domain that signs the mail, so a bad stretch on a sending subdomain is retired and replaced in an afternoon, while the same stretch on your root domain follows your invoices, password resets and replies to customers.

Why does my mail pass SPF and DKIM but fail DMARC?

Because of alignment. DMARC requires that the domain in the visible From header match a domain that passed SPF or DKIM, and with many sending services both passes are on the provider’s domain until the domain setup is finished. Check the d= value in the DKIM-Signature header: it should be your sending domain, not theirs.

Done in this order the whole job is short: one subdomain, an SPF record, the DKIM records your provider hands you, a DMARC record at p=none, two weeks of reading reports, then quarantine and reject. Done in the other order, with a policy published before the records it governs are right, it is a morning of mail that nobody receives and no error message anywhere.

Sources

  1. RFC 7208: Sender Policy Framework
  2. RFC 6376: DomainKeys Identified Mail
  3. RFC 7489: DMARC
  4. DMARC.org: an overview of DMARC
  5. Google’s email sender guidelines

Read next

This page is part of Email deliverability for small senders: authentication and reputation, which is the complete guide to the subject.

These guides are about the format rather than about any particular tool. What this site itself does is on the home page, and the rest of the set is on the guides index .

Elsewhere on this site

The rest of this site comes at the same subject from other directions: guides on the format itself, a tool for one job each, a page for each kind of work, and what to check when choosing software.

Thinking of writing one of these?

5dayemail hosts a five-to-ten day email course: you write it once, and everyone who joins your list gets one email a day, in order, starting from the day they confirm.

Accounts are opened a few at a time rather than by signing up. Leave your address and you will be written to when the next ones open.

One message, when there is room. No course emails, no newsletter, and the address is not passed on. Ask and it is deleted; what is kept, and for how long, is in the privacy policy.