When your invoices land in a customer’s junk folder, or a supplier receives a payment request that looks like it came from your accounts team, the cause is usually three DNS records: SPF, DKIM and DMARC. Together they tell receiving mail servers who is allowed to send for your domain and what to do with anyone pretending to be you.
These records are no longer optional. Since February 2024, the Gmail sender guidelines have required SPF or DKIM from everyone who sends to Gmail accounts, and senders above 5,000 messages a day also need DMARC.
In this article
What each record does
| Record | What it checks | Where it lives in DNS |
|---|---|---|
| SPF | Which servers may send mail for the domain | TXT at the root (@) |
| DKIM | Whether the message was signed by the domain and arrived unchanged | TXT or CNAME at selector._domainkey |
| DMARC | What to do when SPF and DKIM fail, and where to send reports | TXT at _dmarc |
Before you change anything: list everything that sends as your domain
There are almost always more senders than you expect:
- Your mailbox provider (Microsoft 365, Google Workspace or your web host’s email).
- Invoicing, accounting or ERP software that emails documents.
- Website contact forms, newsletter tools and the CRM.
- The multifunction printer that scans to email using an address on your domain.
For each one, note the SPF snippet and the DKIM instructions from the service’s own documentation. Also take a screenshot of the TXT records that already exist in your DNS panel (Cloudflare, your registrar, Hostinger or wherever the zone is hosted).
Step 1: set up SPF (one record only)
SPF is a single TXT record at the root of the domain listing the authorized senders. Each service is added with an include:
| Provider | SPF snippet |
|---|---|
| Microsoft 365 | include:spf.protection.outlook.com |
| Google Workspace | include:_spf.google.com |
| Hostinger email | include:_spf.mail.hostinger.com |
Example with Microsoft 365 plus a billing service:
v=spf1 include:spf.protection.outlook.com include:billing-service.example.com -all
- In your DNS panel, edit the TXT record that starts with
v=spf1(or create one with the name@) and put everyincludein that one record. - Pick the ending. Microsoft’s SPF documentation recommends
-allonce DKIM and DMARC are also in place;~allis softer and useful while you’re still discovering senders.
Companies that switched providers often keep the old SPF record by accident. Check from PowerShell:
Resolve-DnsName yourdomain.com -Type TXT | Select-Object -ExpandProperty Strings

If two lines begin with v=spf1, SPF as a whole returns permerror. It also fails when the total number of lookups goes over 10: every include, a, mx, exists and redirect counts, including the nested ones inside each include; ip4: and ip6: don’t count.
Step 2: turn on DKIM in each service
Microsoft 365. In the Microsoft Defender portal, go to Email & collaboration › Policies & rules › Threat policies › Email authentication settings and open the DKIM tab. Select your domain and use Create DKIM keys; the flyout then shows two CNAME records, selector1._domainkey and selector2._domainkey. On newer domains the target ends in dkim.mail.microsoft, on older ones in onmicrosoft.com, so copy exactly what the portal shows. Once the records are published, turn on Sign messages for this domain with DKIM signatures.
Google Workspace. In the Admin console, open Apps › Google Workspace › Gmail › Authenticate email, choose the domain and click Generate new record. Choose a 2048-bit key if your DNS host accepts it (otherwise 1024) and keep the google prefix. Publish the TXT record at google._domainkey, and only then click Start authentication. Google’s DKIM page notes that authentication can take up to 48 hours to start working.
Hostinger. DKIM comes as three CNAME records (hostingermail-a._domainkey, -b and -c); if your DNS is hosted somewhere else, copy them from hPanel.
Repeat for every item on your list. Invoicing tools, CRMs and newsletter platforms have their own DKIM, usually on a screen called something like “domain authentication”.
Step 3: publish DMARC in monitoring mode first
Create a TXT record named _dmarc:
v=DMARC1; p=none; rua=mailto:dmarc@yourdomain.com
p=noneblocks nothing; it only asks for reports.rua=receives the aggregate reports, typically one a day from each large mailbox provider.
Use a mailbox or group just for this. The reports arrive as compressed XML listing the IP addresses and volumes that sent as your domain, without message content. If you pay a service to read them, treat it like any supplier that receives company data: a contract and restricted access.
When every legitimate service passes in the reports, tighten the policy gradually, as Microsoft’s DMARC guidance describes:
p=quarantine; pct=10, then 25, 50, 75 and 100: the share of failing messages sent to quarantine or the junk folder.p=reject: the receiving server refuses the forged message.
Domains you registered only to protect your brand, and that never send mail, can go straight to v=spf1 -all and v=DMARC1; p=reject.
Step 4: check that it worked
In PowerShell, query DMARC and DKIM (repeat with selector2; for Google, query google._domainkey with -Type TXT):
Resolve-DnsName _dmarc.yourdomain.com -Type TXT | Select-Object -ExpandProperty Strings
Resolve-DnsName selector1._domainkey.yourdomain.com -Type CNAME | Select-Object -ExpandProperty NameHost

Next, send a message to a Gmail account. Open it there, click More (the three dots next to Reply) and choose Show original. The summary at the top should list SPF, DKIM and DMARC as PASS.
To inspect a message you received in classic Outlook, double-click it to open it in its own window, go to File › Properties and read the Internet headers box. In the new Outlook, use More actions › View › View message details. Look for the Authentication-Results line; the values are explained on Microsoft’s anti-spam message headers page.

In this example the forged message failed every check, yet DMARC requested no action (action=none) because the domain was still at p=none. Microsoft’s filter recorded the failure (compauth=fail), but another provider could deliver the same message normally, which is exactly why you shouldn’t stay at the first stage. If someone on your team already replied to a message like this, also follow the hacked email checklist and go over how to spot phishing with the team.
If something fails
Which path to take
| Your situation | Where to start |
|---|---|
| Mailboxes only in Microsoft 365 or Google | SPF with -all, DKIM in the provider’s admin panel and DMARC at p=none, all on the same day |
| Several systems sending as your domain | SPF with ~all, DKIM in each service and a few weeks of reports before moving to quarantine |
| Still choosing an email platform | Read the Google Workspace vs Microsoft 365 comparison; both set up DKIM from their admin panel |
Frequently asked questions
Do I need all three records, or is SPF enough?
All three. SPF doesn’t protect the From address the recipient actually sees; only DMARC tells receivers what to do when someone uses your domain without permission.
Can I start straight at p=reject?
Not on a domain that’s in use. Without the p=none period, a forgotten invoicing or billing system gets its mail rejected, and nobody notices until a customer complains.
Everything is set up and my email still goes to spam. Now what?
Authentication is a prerequisite, not a guarantee. Domain reputation, old mailing lists and content also matter, and Gmail asks senders to keep their reported spam rate below 0.3%.