If you sell anything that plugs into email (a deliverability tool, a CRM add-in, a migration service, an Outlook or Gmail extension), the first question about a lead is simple: is this company on Google Workspace or Microsoft 365?
The usual answer is "look at the MX record". That works for startups. For large companies it mostly fails, because their MX points at a security gateway, not at the mailbox. I measured both cases on 100 real domains and built a ~140-line stdlib Python script that still finds the answer behind the gateway.
The measurement
Two lists of 50 domains each, run on 30 November 2026 against Cloudflare's DNS-over-HTTPS resolver:
- 50 well-known SaaS and tech companies (Stripe, Shopify, Figma, Slack, GitHub, Zoom, Dropbox, OpenAI and so on)
- 50 large non-tech companies (Walmart, Target, JPMorgan Chase, Pfizer, Ford, UPS, Verizon, Deloitte, IBM and so on)
| Tech list | Enterprise list | |
|---|---|---|
| MX points at Google or Microsoft | 42 / 50 | 7 / 50 |
| MX includes a security gateway (Proofpoint, Mimecast, Cisco, Cloudflare) | 8 / 50 | 35 / 50 |
| Of those, Proofpoint | 5 | 30 |
| No MX record at all | 1 | 3 |
| Provider unknown after MX alone | 7 | 40 |
| Provider still unknown after the full script | 0 | 6 |
The tech list is almost all Google Workspace (48 of the 49 domains that receive mail; GitHub is the Microsoft 365 exception). The enterprise list is mostly Microsoft 365 (39 of the 47 domains that receive mail, 14 of them only "likely"; 2 are Google Workspace), but you only see 6 of those 39 if you stop at the MX record. Boeing is one of the 6, on Microsoft's US government cloud. Zendesk lists both Mimecast and Google in its MX, so it appears in two rows.
Four signals, strongest first
-
MX record.
aspmx.l.google.com/smtp.google.commeans Google Workspace;*.mail.protection.outlook.commeans Microsoft 365 (*.protection.office365.usis Microsoft's US government cloud, used by boeing.com). If the MX is*.pphosted.com,*.mimecast.com,*.iphmx.comor*.cf-emailsecurity.net, that's a filtering gateway and you need to keep looking. -
SPF, followed through its includes. SPF lists who may send mail as the domain.
include:_spf.google.comorinclude:spf.protection.outlook.comreveals the mailbox. Many companies nest these one or two levels deep, so the script followsinclude:andredirect=recursively, capped at 10 lookups (the limit in RFC 7208, section 4.6.4). This alone resolved all 7 gateway-only domains in the tech list (Atlassian, Zoom, Dropbox, Salesforce, Cloudflare, Mailchimp and Loom are Google Workspace behind a gateway) and 9 in the enterprise list. -
The autodiscover CNAME. Outlook clients find Exchange Online through
autodiscover.<domain>. When that is a CNAME toautodiscover.outlook.comoroutlook.office.com, the company's mailboxes are in Microsoft 365, gateway or not. This matched 11 enterprise domains (Target, Nike and IBM among them) whose SPF only says "Proofpoint" (often via Proofpoint's hosted-SPF macro%{ir}.%{v}.%{d}.spf.has.pphosted.com, which you can't expand without knowing the sending IP). -
The
MS=ms12345678TXT record. Microsoft 365 asks admins to add it when they verify a domain in a tenant. It proves a tenant exists, not that mail lives there, so the script labels these "Microsoft 365 (likely)". It matched 14 more enterprise domains.
On the enterprise list that took "unknown" from 40 to 6. The remaining 6 (walmart.com, 3m.com, fedex.com, att.com, delta.com, kpmg.com) give nothing away in public DNS. Some have an autodiscover CNAME pointing at their own hostnames (Walmart's points at a hybrid. host, which suggests an on-premises/cloud hybrid), so "self-hosted or hybrid" is the honest answer there.
The script
Standard library only. DNS goes over HTTPS to cloudflare-dns.com, so it also works where outbound port 53 is blocked.
"""Guess which email provider a domain uses, from public DNS only (MX + SPF).
Usage: python3 mailstack.py domains.txt (one domain per line)
Stdlib only; DNS goes over HTTPS to Cloudflare's resolver.
"""
import csv, json, sys, urllib.parse, urllib.request
from concurrent.futures import ThreadPoolExecutor
DOH = "https://cloudflare-dns.com/dns-query?"
# substring of an MX host -> (role, provider)
MX_RULES = [
("aspmx.l.google.com", "inbox", "Google Workspace"),
("googlemail.com", "inbox", "Google Workspace"),
("smtp.google.com", "inbox", "Google Workspace"),
("mail.protection.outlook.com", "inbox", "Microsoft 365"),
("protection.office365.us", "inbox", "Microsoft 365 (US Government)"),
("zoho.", "inbox", "Zoho Mail"),
("messagingengine.com", "inbox", "Fastmail"),
("mx.cloudflare.net", "forwarder", "Cloudflare Email Routing"),
("cf-emailsecurity.net", "gateway", "Cloudflare Email Security"),
("pphosted.com", "gateway", "Proofpoint"),
("ppe-hosted.com", "gateway", "Proofpoint Essentials"),
("mimecast.com", "gateway", "Mimecast"),
("iphmx.com", "gateway", "Cisco Secure Email"),
("barracudanetworks.com", "gateway", "Barracuda"),
("messagelabs.com", "gateway", "Broadcom (Symantec)"),
("trendmicro", "gateway", "Trend Micro"),
("amazonaws.com", "inbox", "Amazon (SES/WorkMail)"),
]
# SPF include -> provider (who is allowed to send as the domain)
SPF_RULES = [
("_spf.google.com", "Google Workspace"),
("spf.protection.outlook.com", "Microsoft 365"),
("spf.protection.office365.us", "Microsoft 365 (US Government)"),
("zoho.", "Zoho Mail"),
("messagingengine.com", "Fastmail"),
("sendgrid.net", "SendGrid"),
("mailgun.org", "Mailgun"),
("amazonses.com", "Amazon SES"),
("servers.mcsv.net", "Mailchimp"),
("mandrillapp.com", "Mailchimp Transactional"),
("_spf.salesforce.com", "Salesforce"),
("hubspotemail.net", "HubSpot"),
("mail.zendesk.com", "Zendesk"),
("spf.mtasv.net", "Postmark"),
("sparkpostmail.com", "SparkPost"),
("_spf.intercom.io", "Intercom"),
("spf.mailjet.com", "Mailjet"),
("customer.io", "Customer.io"),
("pphosted.com", "Proofpoint"),
("mimecast.com", "Mimecast"),
]
INBOXES = {"Google Workspace", "Microsoft 365", "Microsoft 365 (US Government)", "Zoho Mail", "Fastmail"}
def dns(name, rtype):
url = DOH + urllib.parse.urlencode({"name": name, "type": rtype})
req = urllib.request.Request(url, headers={"Accept": "application/dns-json"})
with urllib.request.urlopen(req, timeout=10) as r:
data = json.load(r)
want = {"CNAME": 5, "MX": 15, "TXT": 16}[rtype]
return [a["data"] for a in data.get("Answer", []) if a.get("type") == want]
def txt_records(domain):
# long TXT records come back split into quoted chunks
return [t.replace('" "', "").strip('"') for t in dns(domain, "TXT")]
def spf_record(domain):
return next((t for t in txt_records(domain) if t.lower().startswith("v=spf1")), "")
def spf_tree(domain, budget=None):
"""The SPF record plus every record it pulls in via include: and redirect=,
joined into one string. Stops after 10 lookups, the limit in RFC 7208 4.6.4."""
budget = budget if budget is not None else [10]
record = spf_record(domain).lower()
parts = [record]
for term in record.split():
term = term.lstrip("+-~?")
if term.startswith(("include:", "redirect=")) and budget[0] > 0:
budget[0] -= 1
target = term.split(":", 1)[-1].split("=", 1)[-1]
parts.append(target) # the name itself often identifies the provider
try:
parts.append(spf_tree(target, budget))
except Exception:
pass
return " ".join(parts)
def classify(domain):
mx = sorted(dns(domain, "MX"), key=lambda r: int(r.split()[0]))
hosts = [r.split()[1].rstrip(".").lower() for r in mx]
spf = spf_tree(domain)
mx_hits = [(role, p) for h in hosts for key, role, p in MX_RULES if key in h]
spf_hits = sorted({p for key, p in SPF_RULES if key in spf})
inbox = next((p for role, p in mx_hits if role == "inbox"), None)
evidence = "MX" if inbox else ""
gateway = next((p for role, p in mx_hits if role in ("gateway", "forwarder")), None)
if not inbox:
# Behind a gateway (or self-hosted MX). 1) SPF: who may send as the domain.
inbox = next((p for p in spf_hits if p in INBOXES), None)
evidence = "SPF" if inbox else ""
if not inbox:
# 2) Outlook clients find Exchange Online through autodiscover.<domain>.
cname = " ".join(dns("autodiscover." + domain, "CNAME")).lower()
if "outlook.com" in cname or "office.com" in cname or "office365" in cname:
inbox, evidence = "Microsoft 365", "autodiscover"
if not inbox and any(t.startswith("MS=ms") for t in txt_records(domain)):
# 3) Weakest: the domain was verified in a Microsoft 365 tenant at some point.
inbox, evidence = "Microsoft 365 (likely)", "MS= TXT"
if not hosts:
inbox, evidence = "no MX (domain does not receive mail)", "MX"
return {
"domain": domain,
"inbox": inbox or "unknown / self-hosted",
"evidence": evidence,
"gateway": gateway or "",
"senders": ", ".join(p for p in spf_hits if p not in INBOXES and p != gateway),
"mx": hosts[0] if hosts else "",
}
def safe(domain):
try:
return classify(domain)
except Exception as e: # network error, NXDOMAIN, timeout
return {"domain": domain, "inbox": f"error: {e}", "evidence": "", "gateway": "", "senders": "", "mx": ""}
if __name__ == "__main__":
domains = [l.strip().lower() for l in open(sys.argv[1]) if l.strip() and not l.startswith("#")]
with ThreadPoolExecutor(8) as pool:
rows = list(pool.map(safe, domains))
w = csv.DictWriter(sys.stdout, fieldnames=rows[0].keys())
w.writeheader()
w.writerows(rows)
Run it on a file with one domain per line:
python3 mailstack.py domains.txt > providers.csv
A few real rows from the run:
domain,inbox,evidence,gateway,senders,mx
github.com,Microsoft 365,MX,,"Mailchimp, Salesforce, SendGrid, Zendesk",github-com.mail.protection.outlook.com
atlassian.com,Google Workspace,SPF,Proofpoint,Amazon SES,mxa-001d9801.gslb.pphosted.com
cloudflare.com,Google Workspace,SPF,Cloudflare Email Security,"Mailchimp Transactional, Salesforce, Zendesk",mxa-canary.global.inbound.cf-emailsecurity.net
ibm.com,Microsoft 365,autodiscover,Proofpoint,,mx0a-001b2d05.pphosted.com
nike.com,Microsoft 365,autodiscover,Proofpoint,,mxa-001b6002.gslb.pphosted.com
jnj.com,Microsoft 365 (likely),MS= TXT,Cisco Secure Email,,mx1.jnj-sd.iphmx.com
boeing.com,Microsoft 365 (US Government),MX,,Proofpoint,boeing.mail.protection.office365.us
The evidence column matters. Treat MX and autodiscover as solid, SPF as very likely, and MS= TXT as a hint you'd confirm another way before acting on it.
Bonus: the senders column
SPF also lists the SaaS tools allowed to send as the company, which is a cheap read on the rest of their stack. Across the 50 tech companies, 35 authorise at least one third-party sender: Zendesk 20, Amazon SES 16, Salesforce 15, Mailchimp 7, Mailgun 6, HubSpot 5. The enterprise list is much quieter (most route everything through Proofpoint), so this signal is far more useful on startups and mid-market companies.
Limits, honestly
- Public DNS shows configuration, not usage. A domain can keep an old
include:for years after a migration. That's another reason to keep the evidence column. - Proofpoint's hosted-SPF macro can't be expanded offline, so SPF tells you nothing for those domains. That's why the autodiscover check exists.
- I ran each list once, from one resolver. Records change, so rerun before relying on a specific row.
- Be polite: 8 threads against a public resolver is fine for a few thousand domains. For more than that, run your own resolver.
No-code version
If you only need a handful of domains, the free Tech Stack Checker on siftwright.com reports a site's email provider and DNS provider (from MX, SPF and nameservers) next to its CMS, analytics and hosting, with the evidence for each detection. The free Domain Lookup shows the raw MX, SPF and DMARC records plus domain age. Neither needs a signup. For a whole lead list, the same detection runs in bulk as the Tech Stack Detector on the Apify Store or through the Siftwright API, and you only pay for domains that return a result.
Top comments (0)