SPF, DKIM and DMARC are three DNS records that let receiving servers confirm your email is really from your domain. This guide gives you the records to publish, in the order to publish them, with the values for Google Workspace and Microsoft 365, and shows how to confirm each one works.
You will need access to the DNS settings for your sending domain, usually at the company where you registered it.
What each record does
| Record | Question it answers | Where it lives |
|---|---|---|
| SPF | Is this server allowed to send for the domain? | A TXT record on the domain itself |
| DKIM | Was this message signed by the domain and left unchanged? | A TXT or CNAME record at selector._domainkey |
| DMARC | What should happen to mail that fails, and who gets the reports? | A TXT record at _dmarc |
DMARC adds one idea the other two lack: alignment. SPF and DKIM each check a domain, but not necessarily the one your recipient sees in the From line. DMARC passes only when a domain that passed SPF or DKIM matches the From domain. This is why you can "pass SPF" and still fail DMARC.
Step 1: SPF
Publish one TXT record on the sending domain. The host is usually @ or left blank.
For Google Workspace:
v=spf1 include:_spf.google.com ~all
For Microsoft 365:
v=spf1 include:spf.protection.outlook.com ~all
If more than one service sends as the domain, they go in the same record:
v=spf1 include:_spf.google.com include:sendgrid.net ~all
Three rules cause most SPF failures.
One record only. Two SPF records on the same domain is an error, and SPF fails for everything. If a record already exists, edit it.
Ten lookups at most. Each include costs a DNS lookup, and so does everything inside it. A receiver that has to make more than ten returns a permanent error. You cannot see this by counting the includes you wrote, because each one hides more.
End with ~all or -all. ~all marks unlisted senders as suspicious. -all rejects them outright. Start with ~all and tighten once you are certain the list is complete. Never use +all, which authorises everyone.
Step 2: DKIM
DKIM is set up in two places: you turn signing on with your mailbox provider, and you publish the key it gives you in DNS.
Google Workspace. In the admin console, go to Apps, Google Workspace, Gmail, then Authenticate email. Generate a record, choosing a 2048-bit key if your DNS host accepts it. Google shows a TXT record with a host name such as google._domainkey. Publish it, wait for DNS to update, then return to the admin console and click Start authentication. Until you click that button, nothing is signed.
Microsoft 365. In the Defender portal, open Email authentication settings and choose DKIM. Microsoft gives you two CNAME records, selector1._domainkey and selector2._domainkey, pointing at names under onmicrosoft.com. Publish both, then switch signing on for the domain.
The word before ._domainkey is the selector. It is chosen by the provider, and a domain can have several. This matters when you check your work, because a selector cannot be looked up from the domain alone. A checker has to guess common ones, or be told yours.
To find the selector actually in use, open a message you sent, view its headers and find the DKIM-Signature line. The s= value is the selector and d= is the signing domain. d= must be your domain, not your provider's.
Step 3: DMARC
Publish one TXT record at _dmarc.yourdomain.com. Start with a policy that only monitors:
v=DMARC1; p=none; rua=mailto:dmarc@yourdomain.com
p=none tells receivers to deliver mail as usual and send reports to the rua address. Those reports are XML files listing every server that sent mail as your domain and whether it passed. They arrive daily and are tedious to read by hand, so many people send them to a report-processing service.
The three policies:
| Policy | What receivers are asked to do | When to use it |
|---|---|---|
p=none | Nothing. Report only | While you find every legitimate sender |
p=quarantine | Put failing mail in spam | Once reports show your own mail passing |
p=reject | Refuse failing mail | When you are confident nothing legitimate fails |
Move up one step at a time, with a few weeks of clean reports in between. Jumping straight to p=reject is how companies block their own invoices, because a billing system nobody remembered was sending as the domain without authentication.
For a domain used only for cold outreach, with one mailbox provider and nothing else sending, the list of legitimate senders is short and you can move to enforcement sooner.
Step 4: check your work
DNS changes can take from a few minutes to a day to reach everyone. Then check, because a typo produces no error anywhere.
Then check a real message, which is the only test of alignment. Send an email from the new mailbox to a Gmail address, open it, choose "Show original" and read the top of the page. You want three lines that say PASS: SPF, DKIM and DMARC. If DKIM is missing, signing was never switched on. If DMARC fails while the others pass, the domains do not align.
Common mistakes
- Two SPF records. Usually one from the registrar's default and one you added. Merge them.
- Publishing the DKIM key but never enabling signing. The record exists and nothing uses it.
- The DNS host adding the domain twice. Some control panels append the domain to the host name automatically, turning
_dmarc.acme.cominto_dmarc.acme.com.acme.com. Enter only_dmarcif yours does this. - A long DKIM key pasted as one string. A TXT string holds 255 characters. A 2048-bit key is longer and has to be split into several quoted strings. Many hosts do this for you, and some do not.
- Line breaks or smart quotes picked up when copying from a document.
- Tracking or sending through a service that is not in SPF and does not sign with your domain.
Records for a typical cold email domain
For a domain used only for outreach through Google Workspace, the complete set is small:
| Host | Type | Value |
|---|---|---|
@ | MX | The values Google gives you |
@ | TXT | v=spf1 include:_spf.google.com ~all |
google._domainkey | TXT | The key from the admin console |
_dmarc | TXT | v=DMARC1; p=none; rua=mailto:dmarc@yourdomain.com |
Repeat it for each sending domain. Once the records are in place, plan how many domains and mailboxes you need, and read the infrastructure overview for how the pieces fit together.