
Corporate Mail, Part 2: Domain and DNS — MX, SPF, DKIM, DMARC, PTR, MTA-STS, and Deliverability Verification
🌐 Machine-translated from Russian. Show original
In this part:
Why so many entries#
Recipients' mail servers (Gmail, Outlook.com, Mail.ru, corporate filters) decide where to put your email — in "Inbox," "Spam," or reject it. The decision is based on your domain's DNS records. Without them, even honest emails end up in spam, and scammers can send emails "on your behalf."
Major mail carriers tightened their rules: since February 2024, Gmail requires all senders to have at least SPF or DKIM, while Gmail, Yahoo, and (since May 2025) Outlook.com from bulk senders (at least 5,000 emails per day) require SPF, DKIM, and DMARC. Set up all three at once, even if you have 10 employees.
Below everywhere the domain company.kz — replace it with your own.
Cheat sheet by notes#
| Recording | Where | Why |
|---|---|---|
| MX | company.kz | where to deliver incoming mail |
| SPF (TXT) | company.kz | which servers are allowed to send from the |
| DKIM (TXT or CNAME) | селектор._domainkey.company.kz | public key for verifying the digital signature of a |
| DMARC (TXT) | _dmarc.company.kz | what to do with unverified emails and where to send reports |
| PTR | the IP owner (provider/hosting) | reverse IP → server name (for their server) |
| MTA-STS (TXT + file over HTTPS) | _mta-sts.company.kz | require TLS encryption when delivering to you |
| TLS-RPT (TXT) | _smtp._tls.company.kz | TLS issue reports when delivering to you |
| Autodiscover / autoconfig | CNAME | auto-configuring Outlook and mail clients |
MX — where the mail arrives#
Take values from your service's domain connection wizard , not from articles: Microsoft's MX name is unique for each domain.
| Service | MX (default value) |
|---|---|
| Microsoft 365 | company-kz.mail.protection.outlook.com (exact in the admin center) |
| Google Workspace | smtp.google.com, priority 1 |
| Yandex 360 | mx.yandex.net, priority 10 |
| Own server | mail.company.kz (this name must have an A-record) |
Rule: MX points to a name, not an IP, and that name should not be CNAME.
SPF — who has the right to send#
One TXT record on the domain root. Only one or two records v=spf1 break the validation.
company.kz. TXT "v=spf1 include:spf.protection.outlook.com -all"
Typical include:
| Sender | What to add |
|---|---|
| Microsoft 365 | include:spf.protection.outlook.com |
| Google Workspace | include:_spf.google.com |
| Yandex 360 | include:_spf.yandex.net |
| Your own server | ip4:203.0.113.25 or mx |
| Mailings, CRM, website, | include from the service documentation |
Nuances:
-all— "everyone else is a fake";~all— "suspicious." Start with~all, check all email sources (website, 1C, scanners, CRM), then move on to-all.- Limit — 10 DNS queries when checking SPF (each
include,a,mxcounts). Exceeded — SPF "breaks" (permerror). Remove unnecessary services or transfer them to submission through the main server. - SPF subdomains do not inherit. If the site sends from
noreply@shop.company.kz— a custom record is needed forshop.company.kz.
DKIM — digital signature#
The sender's server signs each email with a private key, and the recipient verifies the signature with the public key from DNS. The signature confirms that the email has not been altered and has been sent by an authorized server.
- Microsoft 365: Microsoft Defender portal → Email & collaboration → Policies → Threat policies → Email authentication settings → DKIM. The portal will show two CNAME records (
selector1._domainkeyandselector2._domainkey) — enter them into the DNS and enable the signature. - Google Workspace: Admin console → Apps → Google Workspace → Gmail → Authenticate email → generate a 2048-bit key → TXT
google._domainkey→ Start authentication. - Yandex 360: domain settings — ready TXT record (selector
mail). - Own server (Mailcow): ARC/DKIM keys section in panel settings — generate a 2048-bit key, enter TXT
dkim._domainkey.
dkim._domainkey.company.kz. TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkqh...длинный ключ..."
Long key: Some DNS panels require splitting into 255-character strings — this is normal, the recipient will merge them.
DMARC — Policy and Reporting#
DMARC links SPF and DKIM to the From address seen by the person (this is called alignment) and tells the recipient what to do if there is a mismatch.
_dmarc.company.kz. TXT "v=DMARC1; p=none; rua=mailto:dmarc@company.kz; fo=1"
| Parameter | Value |
|---|---|
p=none | only collect reports, don't block anything |
p=quarantine | not vetted — to spam |
p=reject | failing the verification — reject |
rua= | where to send daily summary reports (XML) |
pct= | to what share of emails to apply the policy (for a smooth transition) |
sp= | policy for |
Implementation plan:
- Weeks 1–4:
p=none, collecting reports, finding all legitimate sources of letters. - We set SPF/DKIM for each found source (CRM, website, mailings).
p=quarantine; pct=25→pct=100.p=rejectis the ultimate goal. This is the main protection against "director" emails from your domain.
XML reports are inconvenient to read with your eyes — analysis in part 5: Corporate mail, part 5: security — phishing, MFA, DMARC reports, archiving, and backup.
FCrDNS rule: PTR for 203.0.113.25 points to mail.company.kz, and A-record mail.company.kz to 203.0.113.25. And the same name is given by the server in the greeting SMTP (HELO/EHLO). Without PTR, many recipients will simply reject it.
MTA-STS and TLS-RPT — incoming mail encryption#
By default, SMTP encryption is "optional": an attacker in the middle can disable it. MTA-STS tells senders: "deliver to me only via TLS with a valid certificate."
- TXT record (change the
idvalue each time the policy changes):
_mta-sts.company.kz. TXT "v=STSv1; id=20261110T000000"
_smtp._tls.company.kz. TXT "v=TLSRPTv1; rua=mailto:tlsrpt@company.kz"
- HTTPS policy file with a valid certificate at
https://mta-sts.company.kz/.well-known/mta-sts.txt:
version: STSv1
mode: testing
mx: company-kz.mail.protection.outlook.com
max_age: 604800
Start with mode: testing (reports only), and after a couple of weeks without errors — mode: enforce. In the lines mx: list all your MX (mask *.company.kzallowed). If you changed mail services, first update the policy file, then MX.
Autodiscover and client auto-configuration#
- Microsoft 365: CNAME
autodiscover.company.kz → autodiscover.outlook.com. - Own server (Mailcow): CNAME
autodiscoverandautoconfigonmail.company.kz— Outlook and Thunderbird will be configured by address and password.
How to check#
From the command line (Linux/macOS — dig, Windows — nslookup or Resolve-DnsName):
dig +short MX company.kz
dig +short TXT company.kz
dig +short TXT _dmarc.company.kz
dig +short TXT selector1._domainkey.company.kz # для M365 — CNAME, для остальных — свой селектор
dig +short -x 203.0.113.25 # PTR своего сервера
Resolve-DnsName company.kz -Type MX
Resolve-DnsName _dmarc.company.kz -Type TXT
Online inspections:
- mail-tester.com — send a letter to the issued address and receive a score out of 10 with a transcript;
- MXToolbox — checks for MX, SPF, DMARC, blacklists;
- Google Postmaster Tools — your domain reputation in Gmail (requires a noticeable volume of emails);
- in the received email, open the headers (in Gmail — "Show original") and find the line
Authentication-Results: must bespf=pass,dkim=pass,dmarc=pass.
Common mistakes#
| Error | Consequence |
|---|---|
| Two SPF | SPF records don't work for anyone |
| More than 10 include SPF | permerror, spam emails, |
| Forgot website/1C/scanner in SPF | their emails are rejected after -all and p=reject |
| DKIM is included in DNS but not in the service | is not signed |
Immediately p=reject | emails from the CRM and mailings that no one knew about disappeared |
| No PTR on your server | deviations from large mail carriers |
| TTL MX 24 hours when moving | emails go to the old server |
Domain checklist#
- Domain extended with auto-renewal, registrar access is with the company, not the contractor
- MX according to the service wizard
- One SPF record, no more than 10 lookups, final
-all - DKIM 2048 bit enabled for each sender
- DMARC:
none→quarantine→reject, reports are being analyzed - PTR for your server
- MTA-STS and TLS-RPT
- mail-tester rating 9–10 out of 10
Next — launch Microsoft 365: Corporate Mail, part 3: Microsoft 365 — tenant, domain, licenses, synchronization with AD via Entra and MFA.
Comments · 0
No comments yet.Sign in to comment, rate and see all comments.