Every Microsoft 365 tenant is born with a second name. Alongside the domain you paid for, there is the one Microsoft issued at signup, something like examplecompany.onmicrosoft.com, which most administrators see once and never think of again. Microsoft 365 thinks of it constantly. Until told otherwise, it signs your outgoing mail with that name instead of your own.
The signature is valid. The recipient’s server verifies it without difficulty. And DMARC, which asks only whether the signing domain matches the address in the From line, counts it for nothing. Correcting this means one TXT record, two CNAME records, a toggle in a portal with a great many menus, and then a DMARC record to make it all count. Here is the route.
What you are setting up
| Record | Type | DNS name | Value |
|---|---|---|---|
| SPF | TXT | example.com | v=spf1 include:spf.protection.outlook.com -all |
| DKIM | CNAME | selector1._domainkey | Copy from the Defender portal |
| DKIM | CNAME | selector2._domainkey | Copy from the Defender portal |
| DMARC | TXT | _dmarc | You write it |
You will need an administrator role that can manage email authentication settings, and access to the DNS for your custom domain. Run a domain health check first to see what already exists; the MX lookup will confirm that your mail really is routed to Microsoft 365, which is worth knowing before you edit records on that assumption.
Step 1: SPF
For a domain whose mail is sent only through Microsoft 365:
example.com. TXT "v=spf1 include:spf.protection.outlook.com -all"Microsoft’s setup wizard usually prompts for this when a domain is added, so it may already be there. Check before adding another: two SPF records on one domain invalidate each other. If other services send as your domain, their includes belong in the same record:
example.com. TXT "v=spf1 include:spf.protection.outlook.com include:servers.other-sender.example -all"Take the additional includes from each provider’s documentation, and keep the total within SPF’s limit of ten DNS lookups. The SPF checker counts them as a receiving server would. For mail sent by people in Outlook, the envelope sender is on your domain, so SPF passes and aligns. It also fails the moment a recipient forwards the message onward, which is why the next step is not optional.
Step 2: Find and publish the two DKIM CNAME records
Microsoft 365 does not hand you a public key to paste. It hosts the keys itself and asks you to publish two CNAME records that point to them. The exact targets are specific to your tenant and domain, and their format has changed over the years, so the only reliable source is your own portal.
- Sign in to the Microsoft Defender portal at
security.microsoft.com. - Go to Email & collaboration → Policies & rules → Threat policies → Email authentication settings, and open the DKIM tab.
- Select your custom domain from the list. A details pane opens.
- Turn on Sign messages for this domain with DKIM signatures. If the CNAME records are not yet in DNS, the portal declines and displays the two records it expects. That refusal is the useful part: copy both host names and both targets from it.
The records will have this shape:
selector1._domainkey.example.com. CNAME (target shown in the Defender portal)
selector2._domainkey.example.com. CNAME (target shown in the Defender portal)If you prefer a command line, Exchange Online PowerShell reports the same values:
Get-DkimSigningConfig -Identity example.com | Format-List Selector1CNAME, Selector2CNAMECreate both CNAME records at your DNS host exactly as given. Two cautions. Do not reconstruct the targets from an example you found elsewhere; a target built from the wrong pattern resolves to nothing and signing never starts. And if your DNS is at Cloudflare, set both records to DNS only, not proxied, as described in the Cloudflare DNS guide.
Why there are two
Microsoft rotates DKIM keys by alternating between the selectors: while one is signing, the other can be replaced, and then they trade places. Both records must exist for that to work. Publishing only selector1 appears fine until the first rotation, after which every message is signed with a key nobody can look up.
Step 3: Turn signing on
Once the CNAME records resolve, return to the DKIM tab, select the domain, and switch on Sign messages for this domain with DKIM signatures again. This time it should stay on. The PowerShell equivalent is:
Set-DkimSigningConfig -Identity example.com -Enabled $trueIf the portal still cannot find the records, DNS has not caught up yet. The DNS propagation checker shows whether public resolvers can see them, and the DKIM checker, given the selectors selector1 and selector2, confirms that each leads to a usable key. Until a selector has been used for signing, it may not resolve to a key at all; that is expected for the idle one.
Microsoft 365 was signing your mail all along. The task is to get it to sign as you.
Step 4: Verify with a real message
Send a message from a mailbox on your custom domain to an outside address, and view its headers on arrival. In the Authentication-Results header, look for:
spf=pass smtp.mailfrom=example.com;
dkim=pass header.d=example.com;
dmarc=pass header.from=example.comThe value to check is header.d. If it shows your domain, signing is aligned. If it shows a name ending in onmicrosoft.com, the toggle in step 3 has not taken effect. The email header analyzer will find the line for you.
Step 5: Publish DMARC
_dmarc.example.com. TXT "v=DMARC1; p=none; rua=mailto:dmarc-reports@example.com"Begin with p=none, which changes nothing about delivery and starts the daily aggregate reports. Microsoft 365 does not publish this record for you. The DMARC generator builds it; how to configure DMARC explains each tag. To have the reports read for you, add a SpoofKiller address to the rua tag using the reporting setup guide.
The large mailbox providers now expect all of this. Google and Yahoo have required SPF, DKIM, and DMARC from bulk senders since 2024, and Microsoft followed in 2025 with comparable requirements for high-volume mail to its own consumer mailboxes.
The Microsoft 365 corners
Every custom domain is separate
DKIM is enabled per domain. A tenant with five custom domains needs five pairs of CNAME records and five toggles, along with SPF and DMARC records in each domain’s DNS. Subdomains you send from count as domains for this purpose.
The onmicrosoft.com domain
Your tenant’s initial domain can still appear in a From address, for instance on a mailbox that was never given an address at your custom domain. You do not control DNS for that name. The remedy is to make sure every mailbox and shared mailbox sends from a custom domain.
Devices and applications
Scanners, line-of-business applications, and scripts often send mail as your domain by connecting to Microsoft 365 without signing in to a mailbox, or by bypassing it entirely through another mail server. Depending on the method, that mail may not be DKIM-signed for your domain, and may come from an IP address your SPF record does not list. These show up plainly in DMARC reports as failing sources inside your own network. Route them through an authenticated submission method, or give them a subdomain with its own records.
Third-party senders
Marketing, billing, and support platforms do not pass through Microsoft 365 and are unaffected by anything above. Each needs its own DKIM setup with your domain. See alignment explained for why a pass at the provider’s own domain does not help you.
From none to reject
Watch the reports for a few weeks. When every sender you recognize passes, raise the policy to quarantine and then reject, using the checks in how to reach p=reject. DMARC monitoring groups the reports by sender and flags the ones failing alignment, and DKIM monitoring checks on a schedule that both selectors still resolve, which is the thing most likely to break quietly after a DNS migration.
Microsoft gave your tenant two names. With four records and one toggle, your mail finally goes out under the right one.

