Skip to content

How to Add a Custom Domain to Microsoft 365

Add your own domain to Microsoft 365: verify ownership with a TXT record, set the right MX, CNAME, SPF, and DKIM records, and fix common verification failures.

MGMCSA Guru Team July 2, 2026 8 min read
Diagram-style cover showing a custom domain connecting to Microsoft 365 through DNS records for verification and mail flow

Adding your own domain to Microsoft 365 is what turns generic [email protected] addresses into proper [email protected] mail. The process itself is short: prove you own the domain, then publish a handful of DNS records so mail and the Office clients know where to go. The part that trips people up is DNS — one wrong record, or an old MX left in place, and mail either fails verification or quietly lands at the wrong provider.

This walkthrough covers the whole path: adding the domain in the admin center, the TXT record that proves ownership, and the records you actually need afterward (MX, autodiscover, SPF, and DKIM). It also covers the failures that generate most of the support tickets, because almost all of them come down to DNS rather than Microsoft 365 itself.

Before you start

Domain onboarding touches DNS, and DNS changes can break a live website or existing mail if you rush. A few checks first save a lot of grief.

Before you add the domain

  • You're a Global Administrator (or Domain Name Administrator) in the tenant
  • You can sign in to the domain's DNS host (where the nameservers point)
  • You know whether the domain is already handling live email somewhere
  • You've noted any existing MX, SPF, or TXT records so you don't clobber them
  • You have a quiet window planned if this domain already receives mail

Step 1: Add the domain in the admin center

  1. Sign in to the Microsoft 365 admin center (admin.microsoft.com).
  2. Go to Settings → Domains.
  3. Click Add domain.
  4. Type your domain name (for example yourcompany.com) and click Use this domain.

Microsoft now needs to confirm you actually own it before it will route mail. That’s the next step, and it’s done with a single TXT record.

Step 2: Verify ownership with a TXT record

Microsoft generates a unique verification value that looks like MS=ms12345678. You add it as a TXT record at the root of your domain, and Microsoft checks for it.

Verification TXT record

Type TXT
Host / Name @ (the root of the domain)
Value / Points to MS=ms12345678 (use the exact value shown in the portal)
TTL 1 hour (3600) is fine

After you publish the record at your DNS host, return to the wizard and click Verify. If it fails on the first try, that’s almost always propagation lag, not a mistake — wait a few minutes and try again.

Step 3: Choose who manages DNS

After verification, the wizard asks how you want to handle records. You get two practical paths:

  • Let Microsoft set up records (delegated DNS): you repoint the domain’s nameservers to Microsoft and it manages everything. Clean, but it means moving all DNS — including any website records — under Microsoft’s control.
  • Add records yourself: you keep DNS at your current host and add only what Microsoft 365 needs. This is the right choice for almost anyone who already runs a website or other services on the domain.

The rest of this guide assumes you’re adding records yourself, since that’s the common case and the one where mistakes happen.

Step 4: The DNS records Microsoft 365 needs

Here are the records that make mail and the Office clients work. The exact MX and DKIM values include your tenant’s domain key, so copy them from the portal — but the shape is always the same.

Core Microsoft 365 DNS records

MX @ → yourdomain-com.mail.protection.outlook.com (priority 0)
CNAME (autodiscover) autodiscover → autodiscover.outlook.com
TXT (SPF) @ → v=spf1 include:spf.protection.outlook.com -all
CNAME (DKIM selector1) selector1._domainkey → selector1-...._onmicrosoft.com
CNAME (DKIM selector2) selector2._domainkey → selector2-...._onmicrosoft.com

What each one does, in plain terms:

  • MX routes inbound mail to Exchange Online. The hostname is built from your domain (dots become dashes), ending in .mail.protection.outlook.com. Priority is 0.
  • Autodiscover CNAME lets Outlook and phones find the right server automatically when a user sets up the account. Skip it and people end up entering server settings by hand.
  • SPF is a TXT record listing who may send mail for your domain. The Microsoft 365 value is include:spf.protection.outlook.com.
  • DKIM is two CNAMEs that enable cryptographic signing of your outbound mail. They’re published but DKIM itself is switched on separately (Step 5).

If your tenant also uses Teams or Skype for Business calling, the wizard may list extra SRV and CNAME records (sip, lyncdiscover, _sip, _sipfederationtls). Add those only if you use those services — they’re not needed for email.

Step 5: Turn on DKIM

Publishing the two DKIM CNAMEs isn’t enough on its own — you enable signing afterward.

  1. Go to the Microsoft 365 Defender portal (security.microsoft.com).
  2. Open Email & collaboration → Policies & rules → Threat policies → Email authentication settings → DKIM.
  3. Select your domain and switch Sign messages for this domain with DKIM signatures to On.

If the toggle errors out, the CNAMEs usually haven’t propagated yet, or one of them has a typo. Recheck the two selector1 / selector2 records, give DNS time, and try again.

Common verification and mail-flow failures

Most problems land in one of these buckets. Work through them before assuming something is wrong on Microsoft’s side.

What usually goes wrong

Verification keeps failing DNS hasn't propagated, or the TXT value was edited. Paste the exact MS= value and wait.
Record added on the wrong domain You added it at the registrar but nameservers point elsewhere. Add it at the authoritative host.
Host field confusion Some panels want @ for the root; others auto-append the domain. Adding the full domain twice creates yourdomain.com.yourdomain.com.
Mail still hits the old provider Old MX record is still present. Remove it so only the Microsoft 365 MX remains.
Outbound mail marked as spam SPF missing or has two records, and DKIM not enabled. Fix SPF, turn on DKIM.
Outlook won't autoconfigure Autodiscover CNAME missing or pointing somewhere else.

A couple of these deserve a closer look.

The duplicated-domain host trap

DNS panels disagree about the Host (or Name) field. Cloudflare and many others let you type @ for the root and autodiscover for a subdomain, and they append the domain for you. Other panels expect the fully qualified name. If you type autodiscover.yourdomain.com into a panel that auto-appends, you end up with autodiscover.yourdomain.com.yourdomain.com, which resolves to nothing. When a CNAME “just won’t work,” check for the doubled domain first.

Two MX records during a switch

If the domain already received mail elsewhere, you’ll have an existing MX record. Leaving it in place alongside the Microsoft 365 MX means mail can be delivered to either service depending on which record a sender’s server picks. Delete the old MX so only ...mail.protection.outlook.com remains. If mail still isn’t arriving at the new mailboxes after the MX is correct, work through Microsoft 365 email not sending or receiving to check the rest of the mail-flow chain.

Quick verification

Once the records are in and DKIM is on, confirm the domain is genuinely working:

  1. In Settings → Domains, open the domain and check that Microsoft 365 reports Healthy (no missing records flagged).
  2. Send a test message from a new mailbox on the domain to an outside address (Gmail works well) and confirm it arrives in the inbox, not spam.
  3. In Gmail, open the message, choose Show original, and confirm SPF: PASS and DKIM: PASS.
  4. Set up Outlook on the domain account and confirm it configures automatically — that proves the autodiscover CNAME is right.

Wrapping up

Adding a custom domain is mostly a DNS exercise. Verify ownership with the temporary MS= TXT record, then publish the records that matter long term: MX for inbound mail, the autodiscover CNAME for client setup, one clean SPF record, and the DKIM CNAMEs plus the Defender toggle. Keep SPF to a single record, remove any old MX, and watch for the doubled-domain host trap, and verification usually goes through on the first real attempt.

If this domain is part of a wider move onto Microsoft 365, it pairs naturally with planning your mailbox migration — see cutover migration to Microsoft 365 — and once users are live you’ll likely want to set up team addresses with a shared mailbox.

Frequently asked questions

How long does it take to verify a domain in Microsoft 365?

Verification depends on how fast your DNS provider publishes the TXT record. Some hosts update within a few minutes, others take up to an hour, and a few quote up to 72 hours for full propagation. If verification fails right after you add the record, wait and try again rather than recreating the record.

Do I have to let Microsoft manage my DNS?

No. You can delegate the domain so Microsoft manages records for you, or keep DNS at your current host and add the records by hand. Most people who already run a website on the domain keep DNS where it is and add only the records Microsoft 365 needs.

Why is mail still going to my old provider after I added the domain?

Mail follows the MX record. Until you point the MX record at Microsoft 365 and remove the old one, messages keep going to the previous host. Two active MX records pointing at different services is the most common reason mail splits or goes missing during a switch.

What's the difference between the TXT verification record and SPF?

They are two separate TXT records with different jobs. The verification record (it starts with MS=) only proves you own the domain and can be removed afterward. The SPF record lists which servers may send mail for your domain and must stay in place permanently for good deliverability.

Do I need DKIM if I already have SPF?

SPF alone helps, but DKIM signs your outbound mail so receivers can confirm it wasn't tampered with, and the two together let you build a DMARC policy. Enable DKIM in the Microsoft 365 Defender portal after the domain is verified; it noticeably improves deliverability to strict receivers like Gmail.

Can I add a domain I'm already using for email somewhere else?

Yes, but plan the cutover. You verify the domain in Microsoft 365 first without touching mail flow, create the mailboxes, then switch the MX record during a quiet window. Flipping MX before mailboxes exist means inbound mail has nowhere to land.

Sources & further reading

Official vendor documentation referenced while writing this guide.

MG

MCSA Guru Team

IT & Systems Administration

We are working IT pros and system administrators who spend our days in Windows Server, Microsoft 365, and the wider Microsoft stack. MCSA Guru is where we write down the fixes and walkthroughs we wish we had found the first time.

MCSA Guru provides independent, educational IT guidance. Microsoft, Windows, Windows Server, Microsoft 365, Exchange, and Microsoft Teams are trademarks of Microsoft Corporation; Docker is a trademark of Docker, Inc. MCSA Guru is not affiliated with or endorsed by Microsoft or Docker. Always test changes in a safe environment before applying them in production.

Related guides

Fixing something right now?

Jump straight into the guide library or search for the exact error or task you are dealing with.