Skip to Content
Communication Square LLC Help Center

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

RecordAnswers the questionType
SPFWhich servers may send mail for this domain?TXT
DKIMHas this message been altered, and did it really come from us?CNAME x2
DMARCDo SPF or DKIM align with the visible From address, and what policy and reporting apply if DMARC fails?TXT
Note DMARC checks alignment with the visible From address. A message passes DMARC if either aligned SPF or aligned DKIM passes; it fails only if both checks fail. A trusted ARC sealer can help preserve original authentication information when a service modifies inbound mail before delivery.

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
Important The -all ending tells receiving systems to reject mail from sources not authorized by this SPF record. Before publishing it, identify every legitimate sender. If a sender is missing, its mail can fail SPF and may be affected by DMARC. Do not use the Microsoft-365-only value when other services send as your domain.
  1. 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.
  2. 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.
  3. 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.
  4. 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.

  1. In the Microsoft Defender portal, go to Policies and rules, then Threat policies, then Email authentication settings.
  2. Open the DKIM tab and select the custom domain you are configuring.
  3. 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.
  4. 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.
  5. 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.

Defender portal - Policies & rules > Threat policies > Email authentication settings, DKIM tab. Select a domain to see its two CNAME values.

Note Add both CNAME records and give DNS time to update before enabling signing. Enabling before the CNAMEs resolve can produce an error.

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
  1. 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.
  2. 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.
  3. 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.
  4. 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.
Note For custom domains, configure SPF for every custom domain and subdomain used for email. Configure DKIM so the signing domain aligns with the visible From domain. A domain's DMARC record also covers its subdomains unless a subdomain has its own DMARC record. Each subdomain used for mail needs its own SPF and DKIM records for DMARC. For email services outside your direct control, consider using a subdomain rather than the main email domain.

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.

PolicyEffectWhen
p=noneNo instruction for messages that fail DMARC; collect reports.Start here while identifying senders and checking alignment.
p=quarantineAsk receivers to quarantine messages that fail DMARC.Use after reports show legitimate senders are authenticated and aligned.
p=rejectAsk receivers to reject messages that fail DMARC.Use only after you are confident all legitimate senders are accounted for and aligned.
Important Quarantine and reject policies can affect delivery of legitimate messages if a sender is missing or not aligned. Do not jump to p=reject. Review reports and roll out policy changes gradually; if legitimate mail is affected, return to p=none while you identify and fix the sender.
  1. 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.
  2. 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

  1. From an account that sends through Microsoft 365 using your custom domain, send a message to an external address you can inspect.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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 seeWhat to do
SPF fails for your own mailCheck 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 limitReview 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 enableCompare 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 DMARCEdit 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 receivedInspect 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 arriveCheck 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