Email Setup Wizard

Microsoft 365 + Cloudflare

Set up Microsoft 365 email on Cloudflare

The records Microsoft 365 needs, written with the field names Cloudflare uses (Name, Mail server, Content, Target), in the order to add them.

  • 6 steps
  • 7 DNS records
  • Sources checked October 21, 2026

Before you start

  1. Have your Microsoft 365 account ready. Some values are unique to your account and come from the Microsoft 365 admin center.
  2. Open DNS at Cloudflare: Sign in to the Cloudflare dashboard and select your domain. Open the DNS Records page.
  3. Keep both tabs open and add the records below one at a time.

Microsoft 365 also publishes its own guide for Cloudflare: Connect your DNS records at Cloudflare to Microsoft 365 (Microsoft Learn) .

Records to add

Copy each value with the button next to it. Rows marked “Copy from Microsoft 365 admin center” are unique to your account.

Domain verification Proves you own the domain Type TXT Name @ Value Copy from Microsoft 365 admin center Looks like: MS=ms followed by digits Priority n/a TTL 3600 (1 h)
MX records Where incoming email goes Type MX Name @ Value Copy from Microsoft 365 admin center Looks like: <your MX token>.mail.protection.outlook.com, or for domains set up on Microsoft's newer DNSSEC infrastructure <your MX token>.<subdomain>.mx.microsoft Priority 0 TTL 3600 (1 h)
SPF record Which servers may send as you Type TXT Name @ Value v=spf1 include:spf.protection.outlook.com -all Priority n/a TTL 3600 (1 h)
DKIM A signature on every message · recommended Type CNAME Name selector1._domainkey Value Copy from Microsoft 365 admin center Looks like: selector1-yourdomain-com._domainkey.<your onmicrosoft prefix>.<letter>-v1.dkim.mail.microsoft (older domains: selector1-yourdomain-com._domainkey.<prefix>.onmicrosoft.com) Priority n/a TTL 3600 (1 h)
DKIM A signature on every message · recommended Type CNAME Name selector2._domainkey Value Copy from Microsoft 365 admin center Looks like: selector2-yourdomain-com._domainkey.<your onmicrosoft prefix>.<letter>-v1.dkim.mail.microsoft (older domains: selector2-yourdomain-com._domainkey.<prefix>.onmicrosoft.com) Priority n/a TTL 3600 (1 h)
DMARC record What to do with fakes · recommended Type TXT Name _dmarc Value v=DMARC1; p=none; pct=100; rua=mailto:dmarc@yourdomain.com Priority n/a TTL Auto
Autodiscover Automatic app setup · recommended Type CNAME Name autodiscover Value autodiscover.outlook.com Priority n/a TTL 3600 (1 h)

Step by step in Cloudflare

Verify your domain

Your email provider needs proof that you control this domain before it accepts email for it.

Type
TXT
Name
@
Content
Copy it from Microsoft 365 admin center (see below)

Where to find your value

In the Microsoft 365 admin center go to Settings > Domains and add your domain (or select it and choose Start setup). On Verify you own your domain, choose Add a TXT record to the domain's DNS records and copy the TXT value.

It looks like: MS=ms followed by digits

  • This record only proves you own the domain. It doesn't affect anything else and can be deleted after verification.
  • Verification usually takes up to 10 minutes after adding the record, sometimes up to 48 hours.

In Cloudflare

  1. On the DNS Records page, select Add record.
  2. Choose TXT as the Type.
  3. Fill in Name and Content.
  4. Select Save.

Point your MX records

MX records tell every other mail server where to deliver email for your domain. They must point to your provider and nowhere else.

Type
MX
Name
@
Priority
0
Mail server
Copy it from Microsoft 365 admin center (see below)

Where to find your value

In the Microsoft 365 admin center go to Settings > Domains, select your domain, then DNS records > Manage DNS. On the Add DNS records page, expand MX Records and copy the value.

It looks like: <your MX token>.mail.protection.outlook.com, or for domains set up on Microsoft's newer DNSSEC infrastructure <your MX token>.<subdomain>.mx.microsoft

  • Use the highest priority your host allows, typically 0.
  • Remove MX records that point to your previous email provider, or give them a lower priority (a higher number) than the Microsoft 365 record.
  • Add users and mailboxes in Microsoft 365 before switching the MX record so incoming mail keeps flowing.
  • Exchange Online only supports TTL values under 6 hours (21,600 seconds).

In Cloudflare

  1. On the DNS Records page, select Add record.
  2. Choose MX as the Type.
  3. Fill in Name, Mail server and Priority.
  4. Select Save.
  5. Delete any other MX records: select Edit on each one, then Delete, and confirm.

Add the SPF record

SPF is a TXT record that lists the services allowed to send email from your domain, so receivers can spot forgeries.

Type
TXT
Name
@
Content
v=spf1 include:spf.protection.outlook.com -all
  • If an SPF record already exists, don't create a second one. Add include:spf.protection.outlook.com to the existing record so there is a single SPF record.
  • Microsoft recommends -all (hard fail) together with DKIM and DMARC.
  • Only one SPF record is allowed per domain, and it must stay under 10 DNS lookups.

In Cloudflare

  1. On the DNS Records page, select Add record.
  2. Choose TXT as the Type.
  3. Fill in Name and Content.
  4. Select Save.

Set up DKIM (recommended)

DKIM publishes a public key so receivers can confirm your messages really came from you and were not changed on the way.

Type
CNAME
Name
selector1._domainkey
Target
Copy it from Microsoft 365 admin center (see below)

Where to find your value

In the Microsoft Defender portal open Email authentication settings (security.microsoft.com/authentication), select the DKIM tab and your domain, then copy the two CNAME values. They are also shown in the admin center under Add DNS records > Advanced options > DomainKeys Identified Mail (DKIM).

It looks like: selector1-yourdomain-com._domainkey.<your onmicrosoft prefix>.<letter>-v1.dkim.mail.microsoft (older domains: selector1-yourdomain-com._domainkey.<prefix>.onmicrosoft.com)

  • Microsoft lists DKIM as optional, but DMARC needs DKIM to align with your domain.
  • After both CNAME records resolve, turn on Sign messages for this domain with DKIM signatures in the Defender portal.
Type
CNAME
Name
selector2._domainkey
Target
Copy it from Microsoft 365 admin center (see below)

Where to find your value

Same place as selector1: Defender portal > Email authentication settings > DKIM tab > your domain.

It looks like: selector2-yourdomain-com._domainkey.<your onmicrosoft prefix>.<letter>-v1.dkim.mail.microsoft (older domains: selector2-yourdomain-com._domainkey.<prefix>.onmicrosoft.com)

  • Add both selector records. Microsoft rotates between them.

In Cloudflare

  1. On the DNS Records page, select Add record.
  2. Choose CNAME as the Type.
  3. Fill in Name and Target.
  4. Set Proxy status to DNS only (grey cloud).
  5. Select Save.
  6. Repeat for each CNAME record above.

Add the DMARC record (recommended)

DMARC tells receivers what to do with mail that fails SPF and DKIM, and where to send reports about it.

Type
TXT
Name
_dmarc
Content
v=DMARC1; p=none; pct=100; rua=mailto:dmarc@yourdomain.com
  • Start with p=none and read the reports, then move to p=quarantine and finally p=reject. pct can step up in stages (10, 25, 50, 75, 100).
  • Replace the report address with a shared mailbox or group, not a personal inbox.
  • Set up SPF and DKIM first.
  • Microsoft 365 doesn't send forensic (ruf) reports.

In Cloudflare

  1. On the DNS Records page, select Add record.
  2. Choose TXT as the Type.
  3. Fill in Name and Content.
  4. Select Save.

Add the Autodiscover record (recommended)

Autodiscover lets Outlook and other mail apps find your account settings without manual setup.

Type
CNAME
Name
autodiscover
Target
autodiscover.outlook.com
  • Optional but highly recommended: lets Outlook and other apps set up mailboxes automatically.

In Cloudflare

  1. On the DNS Records page, select Add record.
  2. Choose CNAME as the Type.
  3. Fill in Name and Target.
  4. Set Proxy status to DNS only (grey cloud).
  5. Select Save.

Check your setup

Once the records are saved, run a live check. We look up your domain in public DNS and tell you what is right, missing or wrong, with the fix in Cloudflare’s words.

We only read public DNS records. Nothing is stored.

Common mistakes with Microsoft 365 on Cloudflare

Switching MX before adding mailboxes

Add users and mailboxes in Microsoft 365 before changing the MX record, or incoming mail has nowhere to go.

Adding a second SPF record

Microsoft says not to create a new SPF record if one exists. Add include:spf.protection.outlook.com to the existing record so there is a single SPF record.

Publishing DKIM CNAMEs but not turning on signing

After both selector CNAMEs resolve, switch on Sign messages for this domain with DKIM signatures in the Defender portal.

Using a TTL longer than 6 hours on MX

Exchange Online only supports TTL values under 6 hours (21,600 seconds). One hour (3600) is the recommended value.

Cloudflare: Keep email CNAMEs on DNS only

Set Proxy status to DNS only (grey cloud) for DKIM and verification CNAME records. Cloudflare says records used for email or domain verification should not be proxied, and may block proxying DKIM CNAMEs.

Cloudflare: Turn off Cloudflare Email Routing first

If Email Routing is on, Cloudflare has added locked MX records (route1, route2 and route3.mx.cloudflare.net) and an SPF record with include:_spf.mx.cloudflare.net. Unlock them or disable Email Routing (Compute > Email Service > Email Routing > your domain > Settings) before switching to another provider. Email Routing can't be used with an outside mail server.

Rather have someone do it for you?

Tell us your domain and we will add and verify every record for Microsoft 365 on Cloudflare, then send you the check results.

Request done-for-you setup

Microsoft 365 on Cloudflare: questions

Where do I add Microsoft 365 DNS records in Cloudflare?

Sign in to the Cloudflare dashboard and select your domain. Open the DNS Records page. Add each record there, one at a time.

What goes in the Name field at Cloudflare?

Enter @ for records on your bare domain, such as MX and SPF. For the others, enter only the part before your domain, for example autodiscover. Cloudflare adds your domain automatically.

Do I need to delete my existing MX records at Cloudflare?

Remove MX records that point to your previous email provider, or give them a lower priority (a higher number) than the Microsoft 365 record. If Email Routing is on, Cloudflare has added locked MX records (route1, route2 and route3.mx.cloudflare.net) and an SPF record with include:_spf.mx.cloudflare.net. Unlock them or disable Email Routing (Compute > Email Service > Email Routing > your domain > Settings) before switching to another provider. Email Routing can't be used with an outside mail server.

Where do I get my Microsoft 365 DKIM record?

In the Microsoft Defender portal open Email authentication settings (security.microsoft.com/authentication), select the DKIM tab and your domain, then copy the two CNAME values. They are also shown in the admin center under Add DNS records > Advanced options > DomainKeys Identified Mail (DKIM).

Can Microsoft 365 add the records at Cloudflare for me?

Cloudflare supports Domain Connect, so Microsoft 365 and Zoho Mail can add records for you after you sign in and authorize.

How long until Microsoft 365 email works on Cloudflare?

DNS changes typically take about 15 minutes to take effect, occasionally longer.

Sources

Every value and step on this page comes from these official pages. Dashboards change, so if something doesn’t match what you see, tell us.