An MX record tells other mail servers where to deliver email for addresses on your domain. It holds a preference (lower numbers are tried first) and the name of a mail host, for example example.com. 3600 IN MX 1 smtp.google.com.. To set up domain email, keep only one mail provider’s MX records in the DNS zone, point them to a hostname rather than an IP address or a CNAME, and check the result with dig MX your-domain +short.
How we tested
- We pulled the real MX records of well-known organisations on 25.10.2026 over DNS-over-HTTPS from two public resolvers: Google Public DNS (dns.google) and Cloudflare (cloudflare-dns.com). Both returned the same records; only the order differed. We looked at 142 domains in total and show the most telling ones.
- We tested the sender’s logic on the RichHost test bench: an isolated container with 2 vCPU / 8 GB, Ubuntu 24.04, BIND 9.18.39 as a local DNS server, Python 3.11 with dnspython 2.9.0, October 2026. The container cannot send DNS queries to the internet directly, so we reproduced the “primary server down”, “no MX”, “null MX” and common-mistake cases in a .test zone with mail “servers” on 127.0.0.x addresses.
- The ready-made records were checked with
named-checkzone. These are bench results, not measurements of RichHost production servers.
How a sending server picks the MX
When someone writes to info@your-domain, their server looks up the MX records for the part after @ and follows RFC 5321 (section 5.1):
- it sorts the records by preference and tries the lowest number first; records with equal preference are tried in random order to spread the load;
- if the first host does not answer, it moves on to the next one, and if none answers, it queues the message and retries (RFC 5321 suggests not giving up for at least 4-5 days);
- if the domain has no MX at all, it assumes an implicit MX with preference 0 pointing to the domain itself and delivers to its A or AAAA record;
- if the domain publishes a null MX
0 .(RFC 7505), delivery fails at once, with no attempt on the A record and no days of retries.
To see this live rather than on a diagram, we wrote a small script, mx_pick.py (full text below), and ran it on the bench. In the test zone the domain shop has two MX records: 10 for mx1 (nothing listens there) and 20 for mx2 (answers with an SMTP 220 greeting):
$ dig @127.0.0.1 -p 15353 MX shop.rh-test.test +noall +answer
shop.rh-test.test. 300 IN MX 20 mx2.rh-test.test.
shop.rh-test.test. 300 IN MX 10 mx1.rh-test.test.
$ python3 mx_pick.py shop.rh-test.test nomx.rh-test.test parked.rh-test.test
== shop.rh-test.test
DNS order : 10 mx1.rh-test.test, 20 mx2.rh-test.test
try order : 10 mx1.rh-test.test, 20 mx2.rh-test.test
10 mx1.rh-test.test [127.0.0.21]: Connection refused -> next
20 mx2.rh-test.test [127.0.0.22]: connected, 220 127.0.0.22 ESMTP bench <- deliver here
== nomx.rh-test.test
no MX -> implicit MX: the domain itself with preference 0 (RFC 5321 5.1)
0 nomx.rh-test.test [127.0.0.23]: connected, 220 127.0.0.23 ESMTP bench <- deliver here
== parked.rh-test.test
DNS order : 0 .
null MX '0 .' -> domain accepts no mail: bounce at once, never try A (RFC 7505)
Note the first lines of the dig output: the DNS server returned the preference 20 record first. The order in the answer means nothing; only the number counts. The domain parked has both an A record and a null MX, and the script does not even try to connect to its IP.

Real MX records of well-known domains: how to recognise the provider
An MX record tells you at a glance who handles a domain’s mail. This is what the public resolvers returned on 25.10.2026 (DoH answers rewritten in zone-file format, TTL removed):
; Google Workspace, current form: one record
onu.edu.ua. IN MX 1 smtp.google.com.
; Google Workspace, legacy five-record set
kse.ua. IN MX 1 aspmx.l.google.com.
kse.ua. IN MX 5 alt1.aspmx.l.google.com.
kse.ua. IN MX 5 alt2.aspmx.l.google.com.
kse.ua. IN MX 10 alt3.aspmx.l.google.com.
kse.ua. IN MX 10 alt4.aspmx.l.google.com.
; transition: both Google forms
novaposhta.ua. IN MX 1 smtp.google.com.
novaposhta.ua. IN MX 3 aspmx.l.google.com.
; Microsoft 365
ukma.edu.ua. IN MX 0 ukma-edu-ua.mail.protection.outlook.com.
microsoft.com. IN MX 10 microsoft-com.mail.protection.outlook.com.
; null MX (RFC 7505): the domain accepts no mail
example.com. IN MX 0 .
; no MX at all: implicit MX to the A record
gov.ua. (no MX) A 193.29.220.69
- Google Workspace. For new accounts Google recommends a single record,
smtp.google.comwith preference 1. The legacy set,aspmx.l.google.complus alt1-alt4 (and on older domains also aspmx2-5.googlemail.com), still works, and if mail flows with it there is no need to change it. We looked at the MX records of 142 domains of companies, universities and public bodies (our own sample, not representative): of 79 domains on Google, 69 use the legacy set, 9 use the new form, most of them owned by Google itself, and one domain uses both at once. - Microsoft 365. The classic format is the domain name with dashes instead of dots plus
mail.protection.outlook.com. Preferences in real zones differ: 0 for ukma.edu.ua and kyivstar.ua, 10 for microsoft.com, 100 for mit.edu, which confirms that the absolute value does not matter when there is only one record. For domains added to Exchange Online after 1 July 2026, Microsoft issues MX hosts in the newmx.microsoftzone with DNSSEC support (Message Center post MC1048624; the documentation shows values likecontosotest-com.o-v1.mx.microsoft). So do not build the value from a pattern: copy it from the admin center. - Your own server. Names like
mail.your-domainormx1.your-domainmean that mail is received by a hosting server or by the organisation’s own server.
How these records fit together with A, CNAME and TXT in one zone is covered in our guide to DNS records and domain management. A comparison of providers, prices and the full record set for each is in the article on business email on your own domain.
Ready MX records: hosting, Google Workspace, Microsoft 365
We checked each variant below separately with named-checkzone (result: OK). They are alternatives: your zone should contain only one of the blocks. Replace example.com with your domain and 203.0.113.10 with your server’s IP.
; 1. Mail on your hosting server
example.com. 3600 IN MX 10 mail.example.com.
mail.example.com. 3600 IN A 203.0.113.10
; 2. Google Workspace (current form)
example.com. 3600 IN MX 1 smtp.google.com.
; 3. Microsoft 365 (copy the exact host from the admin center)
example.com. 3600 IN MX 0 example-com.mail.protection.outlook.com.
; 4. Domain that accepts no mail (RFC 7505)
example.com. 3600 IN MX 0 .
example.com. 3600 IN TXT "v=spf1 -all"
In the DNS zone of your domain in the hosting control panel you enter the same data into form fields: type MX, name @ (or an empty field for the domain itself), the preference as a separate number, and the mail hostname as the value. MX only affects incoming mail. To keep outgoing messages out of spam, update SPF and DKIM after changing MX, following our SPF, DKIM and DMARC setup guide. If your hosting receives mail but messages from website forms never arrive, the cause is usually not MX: see WordPress not sending emails.
Classic mistakes and how they show up
We deliberately put four of the six classic mistakes into the test zone mistakes.test. This is what named-checkzone says about them:
$ named-checkzone mistakes.test db.mistakes.test
db.mistakes.test:6: warning: '203.0.113.10': MX is an address
zone mistakes.test/IN: a.mistakes.test/MX '203.0.113.10.mistakes.test' has no address records (A or AAAA)
zone mistakes.test/IN: b.mistakes.test/MX 'mail.b.mistakes.test' is a CNAME (illegal)
zone mistakes.test/IN: c2.mistakes.test/MX 'mx.c2.mistakes.test' has no address records (A or AAAA)
zone mistakes.test/IN: d.mistakes.test/MX 'mail.example.net.mistakes.test' has no address records (A or AAAA)
zone mistakes.test/IN: loaded serial 2026102502
OK
Note the last line: the zone loaded with OK, so a DNS server will happily publish broken MX records. And this is how a sender sees the same domains:
$ python3 mx_pick.py a.mistakes.test b.mistakes.test c2.mistakes.test
== a.mistakes.test
10 203.0.113.10.mistakes.test: no A/AAAA -> skip
no usable MX host -> the sender queues and retries or bounces; the mail never arrives
== b.mistakes.test
! mail.b.mistakes.test is a CNAME -> mail.c.mistakes.test. (RFC 2181 10.3: MX must not point to an alias)
10 mail.b.mistakes.test [127.0.0.22]: connected, 220 127.0.0.22 ESMTP bench <- deliver here
== c2.mistakes.test
10 mx.c2.mistakes.test: no A/AAAA -> skip
no usable MX host -> the sender queues and retries or bounces; the mail never arrives
| Mistake | How it shows up | How to fix it |
|---|---|---|
MX points to an IP address (MX 10 203.0.113.10) |
The MX value is always a hostname, so the IP turns into the name 203.0.113.10.your-domain, which does not exist. Mail is not delivered | Create an A record mail with the IP and use mail.your-domain in the MX |
| MX points to a CNAME | The sneakiest one: on the bench the message got through because the resolver followed the alias. But RFC 2181 (section 10.3) forbids it and behaviour depends on the sending server, so the error can “almost work” for years | Replace the CNAME for the mail host with an A or AAAA record |
| No A record for the mail host | has no address records: the sender has nothing to connect to, no mail arrives at all |
Add an A record for the name in the MX or fix the typo in the name |
Two providers mixed (for example, 1 smtp.google.com and 10 mail.your-domain) |
Most mail goes to Google, but some of it, whenever Google is unreachable for a given sender, lands in an old hosting mailbox that nobody reads. With equal preferences mail is split at random: RFC 5321 has senders try equal-preference records in random order | Keep the MX records of one provider only. Split delivery between two services is configured inside the mail service, not with a second MX |
| Trailing dot | In a zone file a name without a final dot gets the domain appended: dig shows 10 mail.example.net.mistakes.test.. Panels can work the other way round: some append the domain themselves, others expect the full name |
After saving, run dig MX your-domain +short: the answer must not contain the domain twice |
| Priorities reversed | If the old server keeps 0 and the new one gets 1, all mail still goes to the old server, and the new one only receives mail during outages | Give the main provider the lowest number and delete the old records |
A script to check your own domain
The script works with any domain when run on a machine with normal DNS. Install: pip install dnspython, run: python3 mx_pick.py your-domain. By default it connects to port 25, which many home ISPs block, so from home the useful part is mostly the MX order and the A records.
#!/usr/bin/env python3
# mx_pick.py: how a sender picks the MX (RFC 5321 5.1, RFC 7505, RFC 2181 10.3)
import argparse, random, socket, dns.resolver
ap = argparse.ArgumentParser()
ap.add_argument("--server"); ap.add_argument("--port", type=int, default=53)
ap.add_argument("--smtp-port", type=int, default=25)
ap.add_argument("domains", nargs="+")
a = ap.parse_args()
r = dns.resolver.Resolver(configure=a.server is None)
if a.server: r.nameservers = [a.server]; r.port = a.port
def q(name, t):
try: return r.resolve(name, t)
except (dns.resolver.NoAnswer, dns.resolver.NXDOMAIN): return None
def addresses(host):
out = []
if q(host, "CNAME"): print(f" ! {host} is a CNAME (RFC 2181 10.3)")
for t in ("AAAA", "A"):
ans = q(host, t)
if ans: out += [x.address for x in ans]
return out
for d in a.domains:
print(f"== {d}")
mx = q(d, "MX")
if mx is None:
print(" no MX -> implicit MX: the domain itself, preference 0")
hosts = [(0, d)]
else:
recs = [(x.preference, str(x.exchange).rstrip(".") or ".") for x in mx]
if len(recs) == 1 and recs[0][1] == ".":
print(" null MX '0 .' -> domain accepts no mail"); continue
random.shuffle(recs) # equal preference = random order
hosts = sorted(recs, key=lambda x: x[0])
print(" try order :", ", ".join(f"{p} {h}" for p, h in hosts))
for pref, h in hosts:
ips = addresses(h)
if not ips: print(f" {pref:>3} {h}: no A/AAAA -> skip"); continue
for ip in ips:
try:
s = socket.create_connection((ip, a.smtp_port), timeout=3)
print(f" {pref:>3} {h} [{ip}]: {s.recv(200).decode().strip()} <- deliver here")
s.close(); break
except OSError as e:
print(f" {pref:>3} {h} [{ip}]: {e.strerror or e} -> next")
else: continue
break
else:
print(" no usable MX host -> queue/retry or bounce")
Without Python you can check MX with dig MX your-domain +short, dig @1.1.1.1 MX your-domain +short (bypassing the local cache) or on Windows with nslookup -type=MX your-domain. The simplest way without a terminal is to open https://dns.google/resolve?name=your-domain&type=MX in a browser: the Answer field shows the preference and the host.
FAQ
How long does a new MX record take to work?
A new record is visible within minutes; a change to an existing one shows up once the old value’s TTL expires. So lower the TTL to 300 seconds a day before the switch. Google warns that new MX records can take up to 72 hours to be recognised, so keep the old mailboxes for a few days.
Do I need a backup MX with another provider?
Usually not. If the main server is down, sending servers queue messages and retry for several days anyway. A backup server that does not know your mailboxes and does not filter spam tends to cause more problems than it solves.
Does a subdomain need its own MX?
Only if it will have addresses, for example user@shop.example.com. The main domain’s MX does not apply to subdomains, so for shop you create a separate record with the name shop.
What should a domain that receives no mail publish?
A null MX 0 . and the SPF record v=spf1 -all, as in the fourth example above. The reserved domains example.com, example.org and example.net do exactly this: senders get a rejection at once instead of waiting for days.
If you prefer to keep mail next to your website, all RichHost hosting plans come with unlimited mailboxes and no mailbox size limits, and the MX for that setup is the first example above.
Sources (checked 25.10.2026)
- RFC 5321, Simple Mail Transfer Protocol (October 2008): section 5.1 on locating the target host and the implicit MX, section 4.5.4.1 on the retry period.
- RFC 7505, A “Null MX” No Service Resource Record (June 2015).
- RFC 2181, Clarifications to the DNS Specification (July 1997): section 10.3, MX must not point to an alias.
- Google Workspace Admin Help: Set up MX records for Google Workspace (updated 22.10.2026).
- Microsoft Learn: Add DNS records to connect your domain (updated 23.04.2026) and How SMTP DANE works (updated 21.07.2026), mx.microsoft format; Message Center post MC1048624 “DNS Provisioning Change” (archived copy).
- Domain MX records: queries to dns.google and cloudflare-dns.com (DoH), 25.10.2026.


