Updated 8 hours ago
Email addresses are a beautiful abstraction. When you write user@example.com, you're addressing a domain—but domains don't receive email. Servers do. MX records bridge that gap, telling the Internet which mail servers speak for a domain.
Without MX records, that email you sent would have nowhere to go. The sending server would stare at "example.com" and have no idea which machine actually accepts mail for it.
What an MX Record Contains
Every MX record carries two pieces of information:
Priority (sometimes called preference): A number that determines which server to try first. Here's the quirk that trips people up: lower numbers mean higher priority. Priority 10 beats priority 20.
Mail server hostname: The fully-qualified domain name of a server that accepts mail.
This tells the world: "example.com has two mail servers. Try mail1 first. If that fails, try mail2."
The Delivery Process
When a mail server needs to deliver a message to recipient@example.com:
1. Extract the domain from the email address (example.com)
2. Query DNS for MX records:
3. Sort by priority (lowest number first)
4. Look up the IP address of the winning server:
5. Connect and deliver via SMTP on port 25
6. On failure, try the next server in the priority list
Priority: The Backwards Ranking System
The priority system feels backwards because it is. Lower numbers win:
- Priority 10 is tried before priority 20
- Priority 20 is tried before priority 30
- The actual numbers don't matter—only their relative order
Convention uses increments of 10 (10, 20, 30) to leave room for inserting servers later. You could use 1, 2, 3 or 100, 200, 300—the behavior is identical.
Equal priorities create load balancing. When multiple servers share a priority, sending servers pick randomly among them:
Incoming mail distributes across all three servers.
Common Configurations
Single server (simple, no redundancy):
Primary with backup (failover):
Load balanced (equal priority):
Cloud email service (Google Workspace example):
Spam filtering service:
Mail routes through the filter first, then the service forwards clean mail to your actual server.
The Rules
MX records have strict requirements:
Must point to hostnames, not IP addresses:
Those hostnames must have A or AAAA records that resolve to actual IP addresses.
Cannot point to CNAMEs. The target hostname needs a direct A/AAAA record:
Every MX record needs a priority value, even if you only have one mail server.
What Happens Without MX Records?
If a domain has no MX records, RFC 5321 says sending servers should fall back to the domain's A record—treating the domain itself as the mail server.
Don't rely on this. Many mail servers reject domains without explicit MX records. It provides no redundancy, no load balancing, and signals misconfiguration. Always set MX records for domains that receive email.
Subdomains Get Their Own Records
Subdomains don't inherit MX records from parent domains:
Email to user@example.com and user@sales.example.com route to different servers. If sales.example.com has no MX record, it can't receive email—it doesn't automatically use the parent's configuration.
TTL: Controlling Cache Duration
The TTL (Time To Live) tells DNS resolvers how long to cache the record:
This record caches for 3600 seconds (one hour).
Before making changes: Lower TTL to 300-600 seconds so the change propagates quickly.
After changes stabilize: Raise TTL back to 3600+ seconds to reduce DNS query load.
Checking Your MX Records
Online tools like MXToolbox provide additional diagnostics.
The Trailing Dot
In DNS zone files, fully-qualified domain names end with a dot:
The trailing dot means "this is the complete name." Without it, some DNS servers append the zone name again.
MX Records and Email Security
MX records interact with SPF in a useful way. The SPF "mx" mechanism authorizes your MX servers to send mail:
This says: "Only the servers in our MX records are allowed to send email for example.com."
Migrating to New Mail Servers
- Lower TTL days before the migration (300-600 seconds)
- Configure new servers completely before touching DNS
- Update MX records to point to new servers
- Wait for propagation (minutes to hours, occasionally longer)
- Keep old servers running briefly to catch cached DNS stragglers
- Migrate mailboxes from old to new
- Raise TTL back to normal values
Frequently Asked Questions About MX Records
Was this page helpful?