Email authentication: SPF, DKIM and DMARC
Reduce spoofing and improve trust in your mail.
Who this is for: Administrators with access to the domain's DNS and to Microsoft 365.
Email authentication helps prevent forged senders and spoofing. If authentication is missing or misconfigured, legitimate messages might go to Junk Email or quarantine.
Scope: This guide configures outbound email authentication for custom domains used with Microsoft 365 cloud mailboxes. It does not cover creating DMARC for an onmicrosoft.com-only domain in the Microsoft 365 admin center, or configuring trusted ARC sealers for inbound mail.
Before you start
- You need a custom domain used for email, access to the DNS hosting service for that domain, and access to the Microsoft Defender portal DKIM settings.
- The source identifies built-in security features for all organizations with cloud mailboxes. It does not specify an additional license or a required admin role for these DNS changes or the DKIM setting.
- No user accounts are created or assigned licenses in this task. If you cannot open the DKIM settings or edit DNS, ask an administrator or DNS provider with the required access to complete that part. Do not make a change until you have access.
- List every service that sends mail using your domain before publishing a restrictive SPF record. Include Microsoft 365 and any other legitimate sending services.
What each one does
| Record | Answers the question | Type |
|---|---|---|
| SPF | Which servers may send mail for this domain? | TXT |
| DKIM | Has this message been altered, and did it really come from us? | CNAME x2 |
| DMARC | Do SPF or DKIM align with the visible From address, and what policy and reporting apply if DMARC fails? | TXT |
SPF
SPF uses one TXT record for the domain to identify authorized sending sources. If Microsoft 365 is the only service that sends mail using the domain, the SPF value is:
v=spf1 include:spf.protection.outlook.com -all
- At the DNS hosting service for your domain, open the DNS records for the domain. If an SPF TXT record already exists, edit that record; do not create a second SPF record.
- If Microsoft 365 is the only sending service, set the SPF TXT record value to v=spf1 include:spf.protection.outlook.com -all. Keep the DNS host or name set for the domain itself, using the format required by your DNS host.
- If other services send mail using your domain, obtain the SPF instruction for each service and combine its authorized source with the Microsoft 365 entry in the single SPF record. Do not publish a second SPF record. If you cannot determine a service's SPF instruction, pause and ask that service's administrator before changing the record.
- Save the DNS record at the DNS host. Confirm that only one SPF TXT record is published for the domain before continuing.
- Include every legitimate service that sends mail as your domain, such as a marketing tool, CRM, website form, scanner, or alerting service.
- Two SPF records for one domain cause SPF to fail; they are not a backup for each other.
- SPF evaluation has a limit of ten DNS lookups. If the record exceeds the limit, reduce or review its lookup-causing entries with the affected sending-service administrators.
DKIM
DKIM signs mail with a domain so recipients can check that important message elements remain unaltered in transit and that the signing domain is authorized.
- In the Microsoft Defender portal, go to Policies and rules, then Threat policies, then Email authentication settings.
- Open the DKIM tab and select the custom domain you are configuring.
- Copy the two CNAME record names and values shown for that domain. At the DNS hosting service for the domain, create both CNAME records using the names and values exactly as shown. Save both records.
- Wait for the CNAME records to resolve in public DNS. Then return to the Microsoft Defender portal, open Policies and rules, then Threat policies, then Email authentication settings, and select the DKIM tab and domain.
- Enable DKIM signing for the domain. If the portal reports that the CNAME records are missing or incorrect, do not keep retrying the enable action; compare both DNS records with the values shown in the portal, correct them, wait for DNS to update, and try again.
Defender portal - Policies & rules > Threat policies > Email authentication settings, DKIM tab. Select a domain to see its two CNAME values.
DMARC
Start with p=none so you can collect reports and learn which services send mail as your domain before asking receiving systems to quarantine or reject messages.
v=DMARC1; p=none; rua=mailto:user@contoso.com
- At the DNS hosting service for your custom domain, open its DNS records and look for a TXT record named _dmarc. If one exists, open it to edit rather than creating another; if none exists, choose to add a TXT record. You should see either the existing record ready to edit or the new-record form.
- Set the TXT record value to v=DMARC1; p=none; rua=mailto:user@contoso.com, replacing yourdomain.com with your domain. Use an address at your domain that is intended to receive aggregate DMARC reports.
- Save the TXT record. Microsoft 365 does not provide an admin portal or PowerShell cmdlet to manage DMARC TXT records for custom domains; create and edit this record at the domain registrar or DNS hosting service.
- Check that the DMARC TXT record resolves publicly with the value you saved. If it does not resolve or the value is wrong, correct the DNS record and check again before changing the policy.
After the record is working, review the aggregate reports sent to the rua address. Identify each legitimate sender and confirm that its SPF or DKIM result aligns with the visible From domain before tightening the policy.
| Policy | Effect | When |
|---|---|---|
| p=none | No instruction for messages that fail DMARC; collect reports. | Start here while identifying senders and checking alignment. |
| p=quarantine | Ask receivers to quarantine messages that fail DMARC. | Use after reports show legitimate senders are authenticated and aligned. |
| p=reject | Ask receivers to reject messages that fail DMARC. | Use only after you are confident all legitimate senders are accounted for and aligned. |
- When reports show that legitimate senders are accounted for and aligned, edit the existing _dmarc TXT record at your DNS host and change p=none to p=quarantine. Save the record and continue reviewing reports.
- If reports remain consistent and legitimate mail is not being affected, edit that same TXT record and change p=quarantine to p=reject. Save the record and continue monitoring reports.
Checking it works
- From an account that sends through Microsoft 365 using your custom domain, send a message to an external address you can inspect.
- Inspect the received message's authentication results. Confirm SPF passes, DKIM passes, and DMARC passes. A passing SPF or DKIM result alone does not prove DMARC passes; at least one passing result must align with the visible From domain.
- If SPF fails, compare the sending service with the authorized sources in the domain's one SPF record. Add or correct the service's SPF instruction and save the existing record, then send another test message.
- If DKIM fails, compare the domain's two CNAME records with the values shown on the DKIM tab, correct any mismatch, wait for DNS to update, and send another test message.
- If DMARC fails, keep the policy at p=none, use the report and message authentication results to identify the unaligned or failing sender, correct its SPF or DKIM setup, and send another test message.
- Check that the DNS records resolve from outside your network. If a new or corrected record is not visible, wait for DNS to update and check again before enabling DKIM or tightening DMARC.
- Review the first DMARC reports at the address in rua before changing from p=none. If reports are not arriving, confirm the DMARC record's rua value and DNS record, correct any error, and check for reports again.
When it goes wrong
| What you see | What to do |
|---|---|
| SPF fails for your own mail | Check whether the sending service is included in the one SPF record. Obtain that service's SPF instruction, update the existing record, and send another test message. |
| The SPF record exceeds the DNS lookup limit | Review the lookup-causing entries with the administrators of the sending services and reduce or correct the entries. Keep one SPF record, then check SPF again. |
| DKIM will not enable | Compare both CNAME names and values with those shown for the domain on the DKIM tab. Correct any mismatch, wait for the CNAMEs to resolve publicly, and retry enabling DKIM. |
| Mail is affected after enabling DMARC | Edit the _dmarc TXT record and return p to none. Review reports and authentication results, identify the legitimate sender that is failing or not aligned, fix its SPF or DKIM configuration, and test again before tightening the policy. |
| A supplier says a message was not received | Inspect the authentication results of a real message and check SPF, DKIM, and DMARC alignment. If a check fails, correct the relevant DNS or signing setup and send a new test message; do not guess at a supplier-specific SPF value. |
| A DMARC report does not arrive | Check that the _dmarc TXT record resolves and that its rua value names the intended report address. Correct the record if needed, save it, and check again for reports. |
Related help articles
Last updated on