Email domain onboarding: secure it before the first user mailbox
CyberSec

📬 Email domain onboarding: secure it before the first user mailbox

The complete checklist for Microsoft 365 and Google Workspace with Cloudflare DNS

The mistake we all make

You register a domain, add it to Microsoft 365 or Google Workspace, create the first mailbox, and start sending email. It works. All good, right?

Not really. You just put a mail domain into production before configuring the two control layers that matter:

SPF, DKIM, and DMARC help receiving servers decide whether a message that claims to be from you is actually authorized. MTA-STS and TLS-RPT protect SMTP delivery to your domain.

This guide defines the secure sequence for bringing a new email domain online: publish and validate the sender-authentication and transport-security controls before the first user mailbox starts sending real mail. Not later. Not “when we have time.” Before.


Prerequisites


Step-by-step process

Step 1. Register the domain

Purchase and register the new domain via your registrar. Keep it parked initially with the parked domain security configuration applied from day one.

Step 2. Add the domain to Cloudflare

Add the domain to your Cloudflare account and configure the nameservers at the registrar to point to Cloudflare. All DNS will be managed from here.

Step 3. Add the domain to your email platform

Microsoft 365:

  1. Log in to Microsoft 365 Admin Center
  2. Go to Settings > Domains > Add domain
  3. Microsoft will provide a TXT verification record - add it in Cloudflare
  4. Confirm verification in Microsoft 365

Official docs: Add a domain to Microsoft 365

Google Workspace:

  1. Log in to Google Workspace Admin Console
  2. Go to Account > Domains > Manage domains > Add a domain
  3. Google will provide a TXT verification record - add it in Cloudflare
  4. Confirm verification in Google Admin

Official docs: Verify your domain for Google Workspace

Step 4. Configure MX and switch from the parked baseline

If you started with a parked-domain baseline, this is the moment to replace it: remove the parked MX, replace the parked SPF record, update report destinations if needed, and remove any parked-domain DKIM cleanup or revocation entries before enabling live mail.

The MX record directs incoming email to your platform’s servers.

Microsoft 365:

TypeNameValuePriority
MXyourdomain.comyourdomain-com.mail.protection.outlook.com0

Official docs: Connect your domain by adding DNS records

Google Workspace (accounts created since April 2023):

TypeNameValuePriority
MXyourdomain.comsmtp.google.com1

Official docs: Set up MX records for Google Workspace

For Google Workspace, remove any other MX records for the domain. After the new MX record is published, go to Account > Domains > Manage domains and click Activate Gmail. MX recognition can take up to 72 hours.

Step 5. Configure sender-authentication records

5.1 SPF

SPF authorizes which servers can send email from your domain.

Microsoft 365:

yourdomain.com TXT "v=spf1 include:spf.protection.outlook.com -all"

Google Workspace:

yourdomain.com TXT "v=spf1 include:_spf.google.com -all"

If you use additional services that send email on your behalf (marketing, support, ticketing, billing, etc.), add them to the same SPF record with extra include: mechanisms. Never publish two SPF records.

5.2 DKIM

DKIM cryptographically signs your outbound mail so the receiver can verify the message was authorized and not modified in transit.

Microsoft 365:

  1. Go to the Defender portal DKIM page: security.microsoft.com/dkimv2
  2. Select your domain
  3. Copy the exact two CNAME targets shown for your tenant
  4. Publish those CNAMEs in Cloudflare
  5. Enable DKIM signing only after the records resolve correctly
TypeNameValue
CNAMEselector1._domainkey.yourdomain.comCopy the exact target shown by Microsoft
CNAMEselector2._domainkey.yourdomain.comCopy the exact target shown by Microsoft

Microsoft’s published examples are illustrative only. The real CNAME targets depend on your tenant’s initial onmicrosoft.com domain and Microsoft routing partition.

Official docs: DKIM in Microsoft 365

Google Workspace:

  1. After Gmail is activated, wait 24-72 hours before generating the DKIM key
  2. In Admin Console, go to Apps > Google Workspace > Gmail > Authenticate email
  3. Generate a new DKIM record
  4. Prefer a 2048-bit key if your DNS provider supports it
  5. Publish the TXT record in Cloudflare
  6. Only after the TXT record is visible in DNS, click Start authentication
TypeNameValue
TXTgoogle._domainkey.yourdomain.comv=DKIM1; k=rsa; p=... (the key Google provides)

Official docs: DKIM in Google Workspace

5.3 DMARC

DMARC tells receiving servers what to do when a message fails SPF or DKIM alignment.

_dmarc.yourdomain.com TXT "v=DMARC1; p=reject; rua=mailto:dmarc-reports@your-report-domain.com;"

For a brand-new domain you fully control, p=reject is a reasonable target after SPF and DKIM are correctly configured and passing in your tests. If you want a softer rollout, start with p=none, validate, and then move to p=reject.

If rua points to another domain, that receiving domain must also publish the authorization TXT record:

yourdomain.com._report._dmarc.your-report-domain.com TXT "v=DMARC1"

Step 6. Configure transport security

Sender authentication and transport security are not the same thing. SPF, DKIM, and DMARC protect your domain’s identity. MTA-STS and TLS-RPT protect SMTP delivery to your domain.

6.1 MTA-STS

MTA-STS tells supporting senders that mail to your domain should be delivered over authenticated TLS, using the MX hosts you publish.

Recommended rollout:

  1. Start in testing mode
  2. Collect and review reports for at least several days, ideally around two weeks
  3. Move to enforce only after the policy validates cleanly

Policy file location:

https://mta-sts.yourdomain.com/.well-known/mta-sts.txt

The host that serves this file must:

Generic policy file:

version: STSv1
mode: testing
mx: <your MX host from step 4>
max_age: 604800

Common examples:

Assertion TXT record:

_mta-sts.yourdomain.com TXT "v=STSv1; id=<YYYYMMDDhhmmssZ>"

Use the current UTC date/time or another unique value for id, and update it every time the policy changes - including when moving from testing to enforce.

6.2 TLS-RPT

TLS-RPT lets supporting senders send you daily reports about TLS and MTA-STS failures they see when trying to deliver mail to your domain.

Mailto example:

_smtp._tls.yourdomain.com TXT "v=TLSRPTv1; rua=mailto:tls-reports@your-report-domain.com"

HTTPS example:

_smtp._tls.yourdomain.com TXT "v=TLSRPTv1; rua=https://reports.your-report-domain.com/v1/tlsrpt"

mailto: and https: are both valid report URIs. For a brand-new domain, an external report mailbox or HTTPS endpoint avoids creating a user mailbox just to receive reports.

Step 7. Validate in two layers

Publishing DNS is only half the job. You also need to confirm the provider is actually signing and serving what you expect.

7.1 Check that DNS is published correctly

nslookup -type=MX yourdomain.com
nslookup -type=TXT yourdomain.com
nslookup -type=TXT _dmarc.yourdomain.com
nslookup -type=TXT _mta-sts.yourdomain.com
nslookup -type=TXT _smtp._tls.yourdomain.com
nslookup -type=CNAME selector1._domainkey.yourdomain.com   # Microsoft 365
nslookup -type=CNAME selector2._domainkey.yourdomain.com   # Microsoft 365
nslookup -type=TXT google._domainkey.yourdomain.com        # Google Workspace

Useful online tools:

7.2 Check that the platform behavior is actually working

Microsoft 365:

Google Workspace:

MTA-STS:

DMARC and TLS-RPT:

Step 8. Create the first user mailbox

Only when steps 1-7 are complete and your test messages behave correctly should the first user mailbox start sending production email.


Validation checklist

ItemStatus
Domain verified in the platform
Parked-domain baseline replaced
MX configured and old MX removed
SPF published as a single record
DKIM published and signing active
DMARC published and report destination working
MTA-STS policy published, reachable over HTTPS, and validated
TLS-RPT published
First test message passes authentication checks
First user mailbox created

Quick reference table - DNS records

Microsoft 365

TypeNameValue
MXyourdomain.comyourdomain-com.mail.protection.outlook.com
TXT (SPF)yourdomain.comv=spf1 include:spf.protection.outlook.com -all
CNAME (DKIM)selector1._domainkey.yourdomain.comCopy the exact target shown by Defender or PowerShell
CNAME (DKIM)selector2._domainkey.yourdomain.comCopy the exact target shown by Defender or PowerShell
TXT (DMARC)_dmarc.yourdomain.comv=DMARC1; p=reject; rua=mailto:dmarc-reports@your-report-domain.com;
TXT (MTA-STS)_mta-sts.yourdomain.comv=STSv1; id=
TXT (TLS-RPT)_smtp._tls.yourdomain.comv=TLSRPTv1; rua=mailto:tls-reports@your-report-domain.com

Google Workspace

TypeNameValue
MXyourdomain.comsmtp.google.com (priority 1)
TXT (SPF)yourdomain.comv=spf1 include:_spf.google.com -all
TXT (DKIM)google._domainkey.yourdomain.comv=DKIM1; k=rsa; p=(key provided by Google)
TXT (DMARC)_dmarc.yourdomain.comv=DMARC1; p=reject; rua=mailto:dmarc-reports@your-report-domain.com;
TXT (MTA-STS)_mta-sts.yourdomain.comv=STSv1; id=
TXT (TLS-RPT)_smtp._tls.yourdomain.comv=TLSRPTv1; rua=mailto:tls-reports@your-report-domain.com

Related reading:


By: Cesar Rosa Polanco - Based on a real-world case, with AI used as an editorial assistant.

First time here?

Explore the key topics and articles on this blog.

Start Here →
← Back to articles Available in Spanish →