Email and collaboration protection with Defender for Office 365 · Prepare

Set up SPF, DKIM and DMARC

SPF and DKIM for every sending domain, then DMARC raised step by step from monitoring to reject.

Duration
6 to 12 weeks, mostly monitoring
Effort
About 4 to 8 person-days, depending on the number of domains and senders
Complexity
Medium
Beyond E5
Nothing beyond Microsoft 365 E5

Who's in the room: Messaging administrator (owner), DNS owner, owners of systems that send email, security operations lead

On this page

Overview

SPF lists the sources allowed to send for a domain. DKIM signs each message so receivers can check it wasn't changed and came from the domain. DMARC tells receivers what to do when SPF or DKIM fail and sends reports back. The onmicrosoft.com domain is handled by Microsoft; custom domains aren't DKIM signed until you set it up. Microsoft recommends a gradual DMARC rollout, ending at reject for every domain.

Technically, you create or update SPF TXT records at the DNS host, turn on DKIM signing for each custom domain in the Defender portal and publish its CNAME records, then publish DMARC TXT records starting at p=none with report addresses, moving to quarantine and reject as reports confirm legitimate mail passes. Parked domains get records saying no mail is ever sent from them.

You'll end up with: Every domain with SPF and DKIM, DMARC at reject for sending domains, parked domains locked down, and reports reviewed.

If you skip it: Without authentication, anyone can send mail that appears to come from the organization, and well-run receivers increasingly junk or reject unauthenticated mail.

Before you start

The path to this playbook

  1. Plan email and collaboration protection
  2. Set up SPF, DKIM and DMARC (you are here)
  • Plan email and collaboration protection: Domains to authenticate, preset or custom policies, who gets Strict protection, and who runs reported messages and quarantine.
  • Have the domain and sender inventory
    How to do it

    Authentication covers every domain and sending service from Plan email and collaboration protection. A sender missing from the list fails once DMARC is enforced.

    Who: Messaging administratorProduces: A domain and sender inventory

  • Choose where DMARC reports go
    How to do it

    Aggregate reports summarize passes and failures; forensic reports give near-immediate detail of failures. Choose a mailbox or a reporting service that can read them.

    Who: Messaging administratorProduces: A destination for DMARC reports

Rollout approach: By risk tier · Pilot size: One low-volume domain or subdomain. Starting with a low-volume domain or subdomain, with few senders, means a missed sender is found before the main domain is at enforcement.

Test to sign-off

4 phases · 2 decisions
  1. Set up SPF1 to 2 weeks

    Create or correct the SPF record for each sending domain and subdomain, listing every legitimate source, and lock down parked domains.

    Who: Messaging administrator with the DNS ownerProduces: SPF records for every domain

    Move on when Each domain has exactly one SPF record that passes for every listed sender.

    Key decisions for this phase (1)

    Where do third-party senders send from?

    Recommended default: A subdomain per third-party service, such as news.example.com

    Bulk and marketing services send large volumes and can harm the reputation of the domain they use. Microsoft recommends a subdomain for services outside your direct control.

    Other options: The main domain for every service · Decided by: Messaging administrator

    How to do it

    Only one SPF record is allowed per domain or subdomain; more than one causes an error. Keep the record under 10 DNS lookups. Microsoft recommends ending the record with -all (hard fail) because DKIM and DMARC are also configured.

    Watch out for (1)
    • If you: Add a second SPF record for a new service

      What tends to happen: SPF returns an error for every message, and the domain's mail fails authentication

      A better approach:

      Edit the existing record to add the service, and check the lookup count

  2. Set up DKIM1 to 2 weeks

    Turn on DKIM signing for each custom domain, publish the CNAME records, and ask each third-party sender to sign with your domain.

    Who: Messaging administrator with the DNS ownerProduces: DKIM signing for every custom domain

    Move on when Test messages from each domain and each third-party sender show DKIM passing with the organization's domain.

    How to do it

    Outbound mail from custom domains isn't DKIM signed until you configure it. DKIM passes DMARC only when the signing domain aligns with the From address domain, so third-party senders need to sign with your domain, not theirs.

    Watch out for (1)
    • If you: Assume Microsoft signs mail for custom domains

      What tends to happen: Mail is signed with the onmicrosoft.com domain, which doesn't align with the From address, so DMARC relies on SPF alone

      A better approach:

      Turn on DKIM for every custom domain and check a sent message's headers

  3. Monitor with DMARC p=none2 to 4 weeks

    Publish DMARC at p=none with report addresses on the pilot domain, then all sending domains, and fix every legitimate sender that fails.

    Who: Messaging administratorProduces: DMARC reports with failing senders fixed

    Move on when Reports show legitimate mail passing for every known sender.

    How to do it

    The DMARC record for a domain also covers subdomains without their own record, but each subdomain still needs its own SPF and DKIM. Parked domains, including onmicrosoft.com if it isn't used for mail, should have records stating that no mail comes from them.

  4. Move to quarantine, then reject4 to 6 weeks

    Raise the policy to p=quarantine, using pct to apply it to a growing share of failing mail, then to p=reject once reports stay clean.

    Who: Messaging administratorProduces: DMARC at reject for every sending domain

    Move on when Every sending domain is at p=reject, and reports are reviewed on a schedule.

    Key decisions for this phase (1)

    How fast do we move to reject?

    Recommended default: Step by step, with at least two clean weeks at each stage

    Microsoft's guidance is to move step by step, monitoring at each stage, and to use pct values below 100 for testing. Moving too fast blocks legitimate mail from a sender nobody listed.

    Other options: Straight to reject · Decided by: Messaging administrator

    Watch out for (1)
    • If you: Stop at p=none

      What tends to happen: Reports arrive, but attackers can still send as the organization and receivers deliver it

      A better approach:

      Plan the dates for quarantine and reject when you publish p=none

Alongside every phase:

Tell the owners of systems that send email why their service needs to change, and give them a date. Most failures at enforcement come from a sender someone set up years ago and forgot.

What keeps it in place:

Receivers apply the DMARC policy to mail that fails, including other Microsoft 365 organizations. Outbound mail from domains with p=quarantine or p=reject that fails DMARC goes through Microsoft's high-risk delivery pool.

How you'll know it's working

3 measures

Capture a baseline before you start, or you won't be able to show the change.

Measures, where you see them, and the direction that means success
MeasureWhere you see itGood direction
Sending domains at DMARC p=rejectDNS and domain inventory Up
Legitimate senders failing DMARCDMARC aggregate reports Down
Spoofed messages using the organization's domainsDMARC reports and spoof intelligence Down

Take it with you

plan, decisions, gate checks, 1 template

Plan outline: phases and when to move on

  1. Set up SPF (1 to 2 weeks). Move on when: Each domain has exactly one SPF record that passes for every listed sender.
  2. Set up DKIM (1 to 2 weeks). Move on when: Test messages from each domain and each third-party sender show DKIM passing with the organization's domain.
  3. Monitor with DMARC p=none (2 to 4 weeks). Move on when: Reports show legitimate mail passing for every known sender.
  4. Move to quarantine, then reject (4 to 6 weeks). Move on when: Every sending domain is at p=reject, and reports are reviewed on a schedule.

Decisions to record, with the recommended answer

DecisionRecommended defaultOur choice
Where do third-party senders send from?A subdomain per third-party service, such as news.example.com
How fast do we move to reject?Step by step, with at least two clean weeks at each stage

Gate checks: questions to answer before each phase ends

Before leaving Set up SPF

  • Does each domain have exactly one SPF record?

Before leaving Set up DKIM

  • Do test messages show DKIM aligned with the From domain?

Before leaving Monitor with DMARC p=none

  • Is every legitimate sender passing in the reports?

Before leaving Move to quarantine, then reject

  • Is every sending domain at p=reject?

Sender inventory row

Domain: [name]. Sender: [service]. Owner: [person]. SPF: [included Y/N]. DKIM: [signs with our domain Y/N]. DMARC result: [pass/fail]. Action: [fix needed].

Microsoft Learn

5 links

Contributor

Compare notes or suggest an improvement

Your message goes straight to Sev Derghazarian.

What would you like to do?

Subject:

The send button is enabled once the spam check below completes.

Changelog

Changelog (1 version)
Published versions of this playbook
VersionDateByChange
1Sev DerghazarianFirst draft.