Detect a company’s email provider from DNS
A domain’s MX records name the host that accepts its inbound mail, and each major provider has a recognisable signature: Microsoft 365 answers with <token>.mail.protection.outlook.com, Google Workspace with smtp.google.com or the older aspmx.l.google.com set, Fastmail with in1-smtp.messagingengine.com. But an MX naming a security gateway — Proofpoint, Mimecast, Barracuda, Cloudflare — tells you nothing about the mailbox behind it. To see through a gateway, check the autodiscover CNAME, the SPF includes, and which DKIM selectors resolve.
One dig query and you usually have it. MX records are public, they change rarely, and every large mail platform hands its customers a hostname you can recognise on sight. The complication is that plenty of business domains put a security gateway in front of the mailbox, and the gateway answers the MX query. When that happens the MX tells you who filters the mail, not who stores it — and you need a second lookup.
What does an MX record actually tell you?
RFC 5321 Section 5.1 describes how a sending SMTP client finds where to deliver: it queries the destination domain for MX records and tries the resulting hosts in order of preference value, lowest number first. If the domain has no MX records at all, the client falls back to the domain’s A or AAAA record — the "implicit MX" — and delivers there.
So an MX record is a statement about inbound delivery and nothing else. It is the address a stranger’s mail server is told to knock on. It says nothing directly about where the domain sends mail from, what the users’ mail client connects to, or who owns the mailbox storage. Those often coincide. Increasingly they do not.
One special case is worth recognising because it saves you an email. RFC 7505 defines a "null MX": a single MX record with preference 0 and a zero-length label — written as a bare dot in a zone file. It exists to make delivery attempts fail immediately. example.com publishes one.
$ dig +short MX example.com
0 .What do the common MX signatures look like?
Each platform publishes a documented hostname its customers must set. That is what makes this readable at a glance. The table below gives the pattern each vendor documents, plus a real domain currently using it — verified with dig while writing this, which is the only kind of example worth printing.
| Platform | MX pattern | Live example | What it means |
|---|---|---|---|
| Microsoft 365 | <MX token>.mail.protection.outlook.com | github-com.mail.protection.outlook.com | Mailbox host. Exchange Online. |
| Google Workspace (current) | smtp.google.com (priority 1) | hubspot.com | Mailbox host. Single-record form. |
| Google Workspace (legacy) | aspmx.l.google.com + alt1/alt2 + aspmx2/3.googlemail.com | stripe.com | Mailbox host. Pre-2023 form, still supported. |
| Zoho Mail | mx.zoho.com (10), mx2.zoho.com (20), mx3.zoho.com (50) | smtpin.zoho.com on zoho.com itself | Mailbox host. Hostnames vary by data centre. |
| Fastmail | in1-smtp.messagingengine.com (10), in2-smtp.messagingengine.com (20) | fastmail.com | Mailbox host. |
| Proofpoint | *.pphosted.com (enterprise), *.ppe-hosted.com (Essentials) | mxa-001d9801.gslb.pphosted.com on atlassian.com | Gateway. Mailbox host unknown. |
| Mimecast | <region>-smtp-inbound-<n>.mimecast.<tld> | de-smtp-inbound-1.mimecast.com on ryanair.com | Gateway. Mailbox host unknown. |
| Barracuda Email Gateway Defense | <id>.ess.barracudanetworks.com | d160221a.ess.barracudanetworks.com on barracuda.com | Gateway. Mailbox host unknown. |
| Cloudflare Email Security | mxa.global.inbound.cf-emailsecurity.net, mxb… | cloudflare.com | Gateway. Mailbox host unknown. |
Two honest caveats about that table. First, Microsoft documents the MX target only as <MX token>.mail.protection.outlook.com and tells admins to read the real token out of the admin centre. The token is often the domain with its dots turned into hyphens — github.com gives github-com — but that is an observation rather than a documented guarantee, and it does break: bt.com answers with btgroupcloud-mail-onmicrosoft-com.mail.protection.outlook.com. Second, we could not find a public Proofpoint or Mimecast page that states these hostname patterns; Proofpoint’s support site redirects an anonymous request to a login page, and Mimecast’s documentation host did not resolve for us at all. So those two rows are what the hostnames resolve to today, not what a vendor document says. Every other row traces to the vendor doc linked at the foot of this page.
A vendor’s own domain is also not always a good template. Zoho tells customers to publish mx.zoho.com, mx2.zoho.com and mx3.zoho.com; zoho.com itself answers with smtpin.zoho.com. Match on the registrable domain, not on an exact hostname.
Why does the MX often name a gateway instead of the mailbox?
Because that is how a pre-delivery email security product is deployed. You point your MX at the vendor, the vendor scans everything, and the vendor relays what survives to your real mail platform over a connector. Barracuda’s documentation is explicit that you "modify all your MX records to point to Barracuda Networks mail servers". Cloudflare’s Email Security setup guide for Microsoft 365 shows the same shape: sender → Cloudflare MX → Exchange Online.
The consequence for anyone reading DNS is direct. A Mimecast MX means Mimecast. It does not mean Exchange, or Google, or an on-premises Postfix — all three sit behind Mimecast at different companies. If your classifier stops at the MX, every gateway customer lands in an "unknown" bucket — two of the five domains sampled later in this article among them.
How do you find the mailbox host behind a gateway?
Three more lookups, in rough order of how much they prove. None of them is conclusive on its own; together they usually settle it.
| Check | Microsoft 365 value | Google Workspace value | Strength |
|---|---|---|---|
| CNAME at autodiscover.<domain> | autodiscover.outlook.com | (none — Google publishes no equivalent) | Strong. Clients use it to configure Outlook. |
| include: in the SPF TXT record | include:spf.protection.outlook.com | include:_spf.google.com | Medium. Proves the platform may send, not that it hosts. |
| DKIM selector that resolves | selector1._domainkey / selector2._domainkey | google._domainkey | Medium. Same caveat as SPF. |
The autodiscover CNAME is the strongest of the three because it exists for a client-side purpose that only a real Exchange Online tenant has. Microsoft’s DNS reference lists it as one of the three primary records every Microsoft 365 email customer sets: alias autodiscover, target autodiscover.outlook.com. Google has nothing equivalent, so its absence is not evidence of anything by itself.
SPF and DKIM are weaker on purpose. An include: mechanism in SPF authorises a platform to send as the domain. A resolving DKIM selector means that platform holds a key that can sign for the domain. Neither says the platform holds the mailboxes. basecamp.com runs its own MX at mx1.basecamp.com and still publishes a google._domainkey TXT record — Google signs some of its mail without hosting it.
Microsoft 365’s DKIM records are CNAMEs at the fixed hostnames selector1._domainkey and selector2._domainkey. The target has two documented shapes: the older selector1-<domain-with-dashes>._domainkey.<tenant>.onmicrosoft.com, and a newer form ending in <tenant>.<partition>-v1.dkim.mail.microsoft, which Microsoft introduced for new custom domains in May 2025 while existing domains keep the old shape. Either target confirms a Microsoft 365 tenant, and both carry the tenant’s initial onmicrosoft.com prefix — github.com’s selector1 points at microsoft.onmicrosoft.com.
$ dig +short MX github.com
0 github-com.mail.protection.outlook.com.
$ dig +short CNAME autodiscover.github.com
autodiscover.outlook.com.
$ dig +short selector1._domainkey.github.com
selector1-github-com._domainkey.microsoft.onmicrosoft.com.A shell function that classifies a domain
This is the whole thing. It reads the MX, matches a signature, and — only when it hits a gateway or an unrecognised host — runs the fall-through checks. It needs dig plus the usual command-line text tools — sort, awk, paste, tr and grep — and it runs identically in bash and zsh.
# mxwho <domain> — guess a domain's mail platform from DNS alone.
mxwho() {
local d=$1 mx spf
mx=$(dig +short MX "$d" | sort -n | awk '{print tolower($2)}' | paste -sd' ' -)
spf=$(dig +short TXT "$d" | tr -d '"' | grep -m1 '^v=spf1')
echo "domain: $d"
echo "mx: ${mx:-(none)}"
case $mx in
*mail.protection.outlook.com*) echo 'verdict: Microsoft 365'; return;;
*aspmx.l.google.com*|*smtp.google.com*) echo 'verdict: Google Workspace'; return;;
*zoho*) echo 'verdict: Zoho Mail'; return;;
*messagingengine.com*) echo 'verdict: Fastmail'; return;;
*pphosted.com*|*ppe-hosted.com*) echo 'verdict: gateway - Proofpoint';;
*mimecast*) echo 'verdict: gateway - Mimecast';;
*barracudanetworks.com*) echo 'verdict: gateway - Barracuda';;
*cf-emailsecurity.net*) echo 'verdict: gateway - Cloudflare';;
'.') echo 'verdict: null MX (RFC 7505) - accepts no mail'; return;;
'') echo 'verdict: no MX - implicit MX on the A record, or no mail'; return;;
*) echo 'verdict: unrecognised - self-hosted or niche';;
esac
# A gateway answered. It says nothing about the mailbox behind it.
echo '--- fall-through checks ---'
case $(dig +short CNAME "autodiscover.$d") in
*autodiscover.outlook.com*) echo 'autodiscover: Microsoft 365';;
esac
case $spf in *spf.protection.outlook.com*) echo 'spf: Microsoft 365';; esac
case $spf in *_spf.google.com*) echo 'spf: Google Workspace';; esac
[ -n "$(dig +short selector1._domainkey."$d")" ] && echo 'dkim: Microsoft 365 (selector1)'
[ -n "$(dig +short TXT google._domainkey."$d")" ] && echo 'dkim: Google Workspace (google)'
[ -n "$(dig +short CNAME fm1._domainkey."$d")" ] && echo 'dkim: Fastmail (fm1)'
return 0 # the && chain above would otherwise leave a false non-zero status
}Run against five real domains, this is the actual output. Note the last two: barracuda.com sits behind its own product with Microsoft 365 underneath, and atlassian.com sits behind Proofpoint with Google Workspace underneath. Neither is visible from the MX alone.
$ for d in github.com hubspot.com atlassian.com barracuda.com example.com; do mxwho $d; echo; done
domain: github.com
mx: github-com.mail.protection.outlook.com.
verdict: Microsoft 365
domain: hubspot.com
mx: smtp.google.com.
verdict: Google Workspace
domain: atlassian.com
mx: mxa-001d9801.gslb.pphosted.com. mxb-001d9801.gslb.pphosted.com.
verdict: gateway - Proofpoint
--- fall-through checks ---
spf: Google Workspace
dkim: Google Workspace (google)
domain: barracuda.com
mx: d160221a.ess.barracudanetworks.com. d160221b.ess.barracudanetworks.com.
verdict: gateway - Barracuda
--- fall-through checks ---
autodiscover: Microsoft 365
dkim: Microsoft 365 (selector1)
domain: example.com
mx: .
verdict: null MX (RFC 7505) - accepts no mailWhy would you want to know before you contact a company?
Two reasons, and they pull in opposite directions.
The first is what happens to mail you send them. A gateway in front of a mailbox changes the receiving behaviour you should expect. It terminates the SMTP connection itself and applies its own policy before deciding what to relay onward. Some of these products also analyse or rewrite the URLs in a message, though exactly what they do varies by vendor and by configuration. If you are debugging why a message to one domain bounced and an identical message to another arrived, the MX is the first place to look, because a pphosted.com or mimecast.com answer means the rejection text you are reading was written by the gateway vendor, not by Exchange or Gmail.
The second is whether a mailbox integration is even possible. Any product that sends through a customer’s own mailbox rather than through a shared relay is bound by what that mailbox’s API allows. Microsoft Graph’s POST /me/sendMail needs the delegated Mail.Send permission and returns 202 Accepted; Gmail has its own send scope. If a prospect’s domain resolves to Zoho, Fastmail or a self-hosted Postfix, a product built only on Graph and the Gmail API cannot connect to it at all — which is a fact worth establishing before a sales conversation, not during one. Decknative connects Microsoft 365 and Gmail mailboxes over OAuth for exactly this reason, and everything else is a "not supported" answer we would rather give up front.
Where does this go wrong?
It is inference, not ground truth, and it fails in recognisable ways. Split-domain and hybrid deployments route some users to a cloud tenant and others to on-premises Exchange, and the MX shows you one path. Large organisations run different platforms per subsidiary while sharing a parent domain. Some companies publish MX records for a domain they never actually receive on. A gateway can front another gateway. And nothing in DNS distinguishes a Microsoft 365 tenant that has Exchange Online licences from one that has only Entra ID.
The other limit is freshness. These records change — the whole point of an MX cutover is that it is a DNS edit — so a classification cached six months ago is a guess about the past. Respect the TTL, re-resolve before you act on the answer, and use a resolver you control rather than a third-party lookup API if the volume is anything but trivial.
Finally: everything here reads records the domain owner published to the public DNS for the express purpose of being read by strangers’ mail servers. That is not a comment on what you may lawfully do with the result. Rules on contacting the people at those domains — the UK and EU GDPR, the UK’s PECR, CAN-SPAM in the US, CASL in Canada — apply regardless of how you discovered the provider, and this article is not legal advice.
Common questions
- Can I tell Microsoft 365 from on-premises Exchange using DNS?
- Usually yes, from the MX. Exchange Online answers with a hostname under mail.protection.outlook.com, while an on-premises Exchange server answers with a hostname in the organisation’s own domain. A hybrid deployment can show either, because mail flow may be routed through on-premises first. The autodiscover CNAME pointing at autodiscover.outlook.com is the better confirmation that a cloud tenant exists.
- Does a Mimecast or Proofpoint MX mean the company uses Microsoft 365?
- No. Those are pre-delivery security gateways that accept mail and relay it onward to whatever platform the customer runs — Exchange Online, Google Workspace, on-premises Exchange or something else. The MX only identifies the filter. Check the autodiscover CNAME, the SPF includes and the DKIM selectors to see what sits behind it, and accept that sometimes none of them resolve.
- What does an MX record of "0 ." mean?
- It is a null MX, defined in RFC 7505: a single MX record with preference 0 and a zero-length label. It is a deliberate declaration that the domain accepts no email, and it exists so delivery attempts fail immediately rather than after days of retries. Treat every address at that domain as undeliverable.
- Why do some Google Workspace domains have five MX records and others one?
- Google introduced a single MX record value, smtp.google.com at priority 1, and domains onboarded before 2023 may still carry the older set beginning with aspmx.l.google.com. Google states the legacy values are still supported and that no change is required if mail is working. Both forms indicate Google Workspace.
- Is checking someone’s MX records legal?
- MX records are public DNS data that a domain owner publishes specifically so that other mail servers can read them, and querying them is an ordinary part of sending email. What you may then do with the result — particularly contacting people at that domain — is governed separately by laws such as the UK GDPR and PECR, CAN-SPAM and CASL. This is not legal advice; take your own.
- Should I use a lookup API instead of dig?
- For a handful of domains, dig is faster and gives you the raw answer with no intermediary. For bulk classification, run your own resolver or use your language’s DNS library so you control caching, honour TTLs and are not rate-limited by a third party. Either way, re-resolve before acting on a stale result — MX records change whenever a company migrates.
- What if the MX is a hostname I do not recognise at all?
- That is common and usually means self-hosting, a regional provider, or a hosting company that runs mail for its customers. Try resolving the MX host to an IP and checking its reverse DNS and ASN, and read the SPF record — a self-hosted setup typically lists its own IPs with ip4: mechanisms rather than delegating with include:. If nothing identifies it, record it as unknown rather than guessing.
Sources
- RFC 5321 — Simple Mail Transfer Protocol, §5.1 Locating the Target Host
- RFC 7505 — A "Null MX" No Service Resource Record for Domains That Accept No Mail
- RFC 7208 — Sender Policy Framework (SPF) for Authorizing Use of Domains in Email, Version 1, §5.2 "include"
- Microsoft — External Domain Name System records for Microsoft 365
- Microsoft — How to use DKIM for email in your custom domain (selector1/selector2 CNAMEs)
- Microsoft Graph — user: sendMail (delegated Mail.Send)
- Google Workspace — Set up MX records for Google Workspace
- Google Workspace — Set up SPF (include:_spf.google.com)
- Google Workspace — Set up DKIM (google._domainkey selector)
- Zoho Mail — Configure email delivery: update MX records
- Fastmail — Setting up your domain: MX only
- Barracuda — How to Configure MX Records to Direct Mail Flow to Barracuda
- Barracuda — How to Set Up MX Records for Domain Verification (the <id>.ess.barracudanetworks.com format)
- Cloudflare — Microsoft 365 as MX Record (Email Security)