SPF, DKIM and DMARC are three DNS records that prove your email really comes from your domain. SPF lists the servers allowed to send for you, DKIM adds a signature that inboxes check against a public key in your DNS, and DMARC tells inboxes what to do when those checks fail and sends you reports. To set them up, publish one SPF record that covers every sending service, turn on DKIM in each service, then add a DMARC record at p=none and tighten it to quarantine and reject once the reports show your real mail passing.
This guide is for business owners, office managers and developers who look after a domain's email. It gives the exact record formats, the limits that quietly break them, and the order to make changes so you never block your own invoices. If you want the background on why owning your domain and email matters first, read domain and business email setup.
#What each record does
Each record answers a different question a receiving inbox asks about your message. Together they let Gmail, Outlook and Yahoo tell your real mail apart from forgeries.
| Record | Where it lives | The question it answers | Standard |
|---|---|---|---|
| SPF | TXT record on your domain (or bounce subdomain) | Is this server allowed to send for the envelope domain? | RFC 7208 |
| DKIM | TXT or CNAME at selector._domainkey.yourdomain | Was this message signed by the domain in d=, and is it unchanged? | RFC 6376 |
| DMARC | TXT record at _dmarc.yourdomain | Does a passing check match the From domain, and what should happen if not? | RFC 9989 (replaced RFC 7489 in May 2026) |
Two details explain most failures. First, SPF checks the envelope sender, also called the Return-Path or bounce address, not the From address people see. Many sending services use their own bounce domain, so SPF passes for them but says nothing about your domain. Second, DKIM signs with whatever domain the service puts in d=. If that is the service's domain rather than yours, the signature passes but does not help your DMARC. That is why alignment matters, and why each service needs to be set up on your domain.
- List every sender
- Build one SPF record
- Turn on DKIM per service
- Publish DMARC p=none
- Read reports for a few weeks
- Quarantine
- Reject
#Step 1: list every service that sends as your domain
Before touching DNS, write down everything that sends email with your domain in the From address. Missing one is the most common reason DMARC later blocks real mail.
- Your mailbox provider, for example Google Workspace or Microsoft 365.
- Your website: contact forms, WooCommerce order emails, password resets. These should go through a proper SMTP service, not the web server's own mail function. See SMTP and transactional email setup if yours does not.
- Marketing tools such as a newsletter platform.
- Business software: invoicing, CRM, helpdesk, booking, payroll.
- Any server or app you run yourself that sends notifications.
For each one, note whether it gives you an SPF include, DKIM records, and a custom bounce (Return-Path) domain option. Their setup pages list these.
#Step 2: publish one SPF record
SPF is a single TXT record on your domain that starts with v=spf1, lists allowed senders, and ends with an all rule. Google Workspace's documented record is:
v=spf1 include:_spf.google.com ~allMicrosoft 365's documented record is:
v=spf1 include:spf.protection.outlook.com -allIf you use both a mailbox provider and other services, merge them into one record. Google's own example for Workspace plus Mailchimp is v=spf1 include:_spf.google.com include:servers.mcsv.net ~all.
The rules that break SPF most often:
- Only one SPF record per domain. RFC 7208 says a domain must not have more than one, and Microsoft's documentation confirms that multiple SPF records return
permerror. When a new tool tells you to "add an SPF record", edit the existing one instead. - The 10 lookup limit. The
include,a,mx,ptrandexistsmechanisms and theredirectmodifier each cost a DNS lookup, and includes inside includes count too. Over 10, SPF fails.ip4,ip6andallcost nothing. - Void lookups. RFC 7208 recommends failing after two lookups that return nothing, so remove includes for services you no longer use.
- Do not use
ptr. The RFC says it should not be published. - Syntax. No trailing dot, a colon not an equals sign after
include, and no space after the colon.
On the ending: -all (fail) says unlisted servers are not allowed, ~all (softfail) says they probably are not. Google recommends ~all; Microsoft recommends -all because DMARC handles the final decision. Either works once DMARC is in place. Use ?all only for testing.
If you are near 10 lookups, Microsoft suggests moving bulk tools to a subdomain such as news.yourdomain.com, which gets its own SPF record and its own 10 lookups, or dropping unused services. Replacing includes with fixed IP addresses ("flattening") works only for providers whose IPs rarely change, and Microsoft warns never to flatten its own include.
#Step 3: turn on DKIM for each service
DKIM is switched on inside each sending service, which then gives you DNS records to publish. The public key lives at selector._domainkey.yourdomain.com, where the selector is a name chosen by the service. Selectors let several services sign for the same domain without clashing.
| Service | What you publish | Selector name |
|---|---|---|
| Google Workspace | One TXT record generated in the Admin console | google by default |
| Microsoft 365 | Two CNAME records | selector1 and selector2 |
| Amazon SES (Easy DKIM) | CNAME records shown in the SES console | Generated tokens |
| Newsletter, CRM or helpdesk tools | CNAME or TXT records from their setup page | Set by the tool |
Google Workspace. In the Admin console, generate a key for each domain, choose 2048 bits if your DNS host accepts long TXT values (1024 if not), publish it at google._domainkey, then click Start authentication. Google notes the console can keep showing a warning for up to 48 hours.
Microsoft 365. Publish the two CNAME records shown in the Defender portal for your domain. Newer tenants point to a host ending in dkim.mail.microsoft; older ones point to your onmicrosoft.com domain. Copy the exact values from the portal, then enable signing.
Everything else. Use the records the tool gives you. Amazon SES, for example, signs with a 2048 bit key by default.
Key length matters: RFC 6376 requires at least 1024 bits, Google requires at least 1024 bits for mail to personal Gmail accounts and recommends 2048. To retire an old key, RFC 6376 allows publishing the selector with an empty p= value, which marks it revoked.
#Step 4: publish DMARC and understand alignment
DMARC is a TXT record at _dmarc.yourdomain.com. A safe starting record looks like this:
v=DMARC1; p=none; rua=mailto:dmarc-reports@yourdomain.comThe main tags:
| Tag | Meaning | Values |
|---|---|---|
v | Version, must come first | DMARC1 |
p | Policy for mail that fails | none, quarantine, reject |
rua | Where daily aggregate reports go | One or more mailto: addresses |
sp | Policy for subdomains | Same as p |
adkim, aspf | Alignment mode for DKIM and SPF | r relaxed (default) or s strict |
pct | Share of failing mail the policy applies to | 0 to 100 (see the note on RFC 9989 below) |
Alignment, in plain words. DMARC does not just ask "did SPF or DKIM pass?" It asks "did one of them pass for the same domain as the From address?" With relaxed alignment, the default, the organisational domains must match, so a DKIM signature for mail.yourdomain.com aligns with a From address at yourdomain.com. With strict alignment the names must be identical. A message passes DMARC if either SPF or DKIM passes and aligns. Google says relaxed is usually enough, and suggests strict only when other parties control your subdomains.
This is why each sending service must sign with your domain (DKIM) or use a bounce subdomain of yours (SPF). A service that signs as itself will pass its own checks and still fail your DMARC.
If your rua address is on a different domain, such as a reporting service, that domain must publish a record authorising it, in the form yourdomain.com._report._dmarc.reportingservice.com. Reporting services set this up for their customers.
#Step 5: move from p=none to reject safely
Do not jump straight to reject. Read the reports first, fix every real sender that fails, then tighten in stages.
- Wait for SPF and DKIM. Google asks for SPF and DKIM to be running for at least 48 hours before you add DMARC.
- Monitor at
p=none. Google suggests about a week of daily review for a typical organisation. RFC 9989 is more cautious and describesp=nonefor at least a month before changing. With several sending tools, give it a few weeks so monthly invoices and newsletters show up. - Fix what fails. Every legitimate source in the reports must pass SPF or DKIM with alignment. How to read them is covered in DMARC reports and monitoring.
- Quarantine. Failing mail goes to spam. Google's example starts small:
v=DMARC1; p=quarantine; pct=5; rua=mailto:dmarc@example.com, then raises the percentage to 100. - Reject. Failing mail is refused. RFC 9989 suggests holding quarantine for about as long as you held
p=nonebefore this step.
Mailing lists are the main exception. RFC 9989 advises that domains whose staff post to mailing lists should not publish p=reject, because lists often change messages and break signatures.
#When to get help
You can do this yourself if one mailbox provider is the only thing sending as your domain: its own setup pages give you the exact records. Get help when several tools send as you, when your SPF record is near 10 lookups, when DMARC reports show sources you do not recognise, or when mail is already landing in spam. A wrong change at reject can bounce your own invoices without anyone noticing for days.
That audit and staged rollout is what my email deliverability service covers. If your website sends through the server's default mail function, fix that first with SMTP and transactional email setup, and if mail is already going to spam, start with why emails go to spam and how to fix it.
Frequently asked questions
Can I have two SPF records on one domain?
No, a domain can have only one SPF record. Two records make receivers return a permanent error, so SPF fails for everything. Merge all senders into one record that starts with v=spf1 and ends with a single all rule.
What is a DKIM selector?
A selector is the name a sending service uses to publish its DKIM public key, at selector._domainkey.yourdomain.com. It lets several services sign mail for the same domain with different keys. Google Workspace uses google by default and Microsoft 365 uses selector1 and selector2.
Should my SPF record end in ~all or -all?
Either is acceptable once DKIM and DMARC are set up, because DMARC makes the final decision. Google recommends ~all for Workspace domains, while Microsoft recommends -all for Microsoft 365 domains. Never use +all, which allows any server in the world to send as you.
How long should DMARC stay at p=none?
Stay at p=none until your reports show every legitimate sender passing with alignment. Google suggests about a week for review, while RFC 9989 describes at least a month. Businesses with monthly invoices or newsletters should wait at least one full sending cycle.
What is the difference between relaxed and strict alignment?
Relaxed alignment, the default, accepts a match on the main domain, so mail.example.com aligns with example.com. Strict alignment needs the exact same domain name. Relaxed is right for most businesses.
Sources
The facts in this article were checked against these pages, last reviewed 12 November 2026.
- RFC 7208: Sender Policy Framework (SPF), IETFrfc-editor.org/rfc/rfc7208.html
- RFC 6376: DomainKeys Identified Mail (DKIM) Signatures, IETFrfc-editor.org/rfc/rfc6376.html
- RFC 9989: Domain-Based Message Authentication, Reporting, and Conformance (DMARC), IETFrfc-editor.org/rfc/rfc9989.html
- RFC 7489: DMARC (now obsoleted), IETFrfc-editor.org/rfc/rfc7489.html
- Set up SPF, Google Workspace Helpknowledge.workspace.google.com/admin/security/set-up-spf
- Set up DKIM, Google Workspace Helpknowledge.workspace.google.com/admin/security/set-up-dkim
- Set up DMARC, Google Workspace Helpknowledge.workspace.google.com/admin/security/set-up-dmarc
- Recommended DMARC rollout, Google Workspace Helpknowledge.workspace.google.com/admin/security/recommended-dmarc-rollout
- Set up SPF for your Microsoft 365 domain, Microsoft Learnlearn.microsoft.com/en-us/defender-office-365/email-authentication-spf-configure
- How to use DKIM for email in your custom domain, Microsoft Learnlearn.microsoft.com/en-us/defender-office-365/email-authentication-dkim-configure
- Easy DKIM in Amazon SES, AWS Documentationdocs.aws.amazon.com/ses/latest/dg/send-email-authentication-dkim-easy.html




