Understanding MX records: what they are, how they route email, MX record priority, and how to configure MX records correctly for email delivery.
MX Records Explained: How Email Routing Works
What is an MX Record?
An MX (Mail Exchange) record is a DNS record that specifies which mail server(s) are responsible for receiving email for a domain. It's the fundamental mechanism that enables email delivery across the internet.
How MX Records Work
When someone sends you an email:
- Sender mail server looks up MX records for your domain
- DNS query returns one or more MX records
- Priority check: Server tries highest priority (lowest number) first
- Connection: Attempts SMTP connection to mail server
- Delivery: Email delivered if connection succeeds
- Fallback: Tries next priority if first server fails
MX Record Structure
example.com. MX 10 mail1.example.com.
example.com. MX 20 mail2.example.com.
Components:
example.com.: Domain receiving emailMX: Record type10,20: Priority (lower = higher priority)mail1.example.com.: Mail server hostname
MX Priority Explained
How Priority Works
Lower number = Higher priority
example.com. MX 10 primary.mail.com. ← Tried FIRST
example.com. MX 20 secondary.mail.com. ← Backup
example.com. MX 30 tertiary.mail.com. ← Last resort
Same Priority = Load Balancing
example.com. MX 10 mail1.example.com.
example.com. MX 10 mail2.example.com.
Result: Traffic split between both servers
Priority Best Practices
✅ Primary: 10
✅ Backup: 20, 30, 40, etc.
✅ Gap: Leave space (10, 20, 30) not (10, 11, 12)
❌ Don't use: Priority 0 (reserved)
Common MX Configurations
Google Workspace
example.com. MX 1 aspmx.l.google.com.
example.com. MX 5 alt1.aspmx.l.google.com.
example.com. MX 5 alt2.aspmx.l.google.com.
example.com. MX 10 alt3.aspmx.l.google.com.
example.com. MX 10 alt4.aspmx.l.google.com.
5 servers: High redundancy
Microsoft 365
example.com. MX 0 example-com.mail.protection.outlook.com.
Single MX: Microsoft handles redundancy
Zoho Mail
example.com. MX 10 mx.zoho.com.
example.com. MX 20 mx2.zoho.com.
example.com. MX 50 mx3.zoho.com.
3 servers: Primary + backups
Self-hosted (Simple)
example.com. MX 10 mail.example.com.
Single server: No redundancy
Self-hosted (Redundant)
example.com. MX 10 mail1.example.com.
example.com. MX 20 mail2.example.com.
Two servers: Primary + backup
MX Record Errors
1. No MX Records
Error: No MX records found for example.com
Problem: Can't receive email
Solution: Add MX record in DNS
2. MX Points to CNAME
example.com. MX 10 mail.example.com.
mail.example.com. CNAME hosting.example.net.
❌ Invalid: MX can't point to CNAME
✅ Fix: MX must point to A record
example.com. MX 10 mail.example.com.
mail.example.com. A 192.0.2.1
3. MX Points to IP
example.com. MX 10 192.0.2.1
❌ Invalid: MX needs hostname
✅ Fix:
example.com. MX 10 mail.example.com.
mail.example.com. A 192.0.2.1
4. Missing A Record
example.com. MX 10 mail.example.com.
# But mail.example.com has no A record
Problem: Can't resolve IP
Solution: Add A record
mail.example.com. A 192.0.2.1
5. Multiple MX, All Same Priority
example.com. MX 10 mail1.example.com.
example.com. MX 10 mail2.example.com.
example.com. MX 10 mail3.example.com.
⚠️ Warning: Load balancing only
✅ Better: Add backup priorities
Setting Up MX Records
Step 1: Choose Mail Provider
Options:
- Google Workspace (business)
- Microsoft 365 (business)
- Zoho Mail
- Self-hosted (Postfix, etc.)
Step 2: Get MX Values
Provider gives you:
- Hostnames
- Priorities
- Optional: TXT records (SPF, DKIM)
Step 3: Add to DNS
Example (Cloudflare):
DNS → Add Record
Type: MX
Name: @
Mail server: aspmx.l.google.com
Priority: 1
TTL: Auto
Step 4: Wait for Propagation
DNS propagation: 1-48 hours
- Most changes: 1-4 hours
- Full global propagation: 24-48 hours
Step 5: Test
Send test email:
your-email@example.com
Check delivery:
- Inbox received? ✅
- Bounce? Check MX records
- Spam? Check SPF/DKIM
Verifying MX Records
Method 1: MXToolbox.eu
1. Go to MX Lookup tool
2. Enter domain
3. Click "Lookup"
4. View all MX records + IP addresses
Method 2: Command Line
Mac/Linux:
dig example.com MX +short
Windows:
nslookup -type=MX example.com
Output:
10 mail.example.com.
MX Record Best Practices
Redundancy
✅ Multiple servers: Minimum 2
✅ Different priorities: Primary + backup
✅ Different locations: Geographic redundancy
Configuration
✅ Valid hostnames: Not IPs
✅ A records exist: For all MX targets
✅ No CNAMEs: MX → A record only
✅ Priority gaps: Room to insert
Security
✅ SPF record: Authorize mail servers
✅ DKIM: Sign outgoing emails
✅ DMARC: Enforce authentication
✅ TLS: Encrypted connections
Troubleshooting Email Delivery
Emails Not Arriving
Check:
- MX records exist? ✅
- MX records correct? ✅
- A records resolve? ✅
- Mail server running? ✅
- Firewall allows port 25? ✅
- SPF record valid? ✅
Emails Bouncing
Common causes:
- No MX records
- Wrong MX hostname
- Mail server down
- Mailbox full
- Blacklisted IP
MX vs Other DNS Records
| Record | Purpose |
|---|---|
| MX | Email delivery routing |
| A | Maps hostname → IPv4 |
| AAAA | Maps hostname → IPv6 |
| CNAME | Alias (not for MX!) |
| TXT | SPF, DKIM, DMARC |
Migrating Email Providers
Safe Migration Process
Lower TTL (24h before migration)
example.com. MX 10 old-mail.com. (TTL: 300)Add new MX (parallel)
example.com. MX 10 old-mail.com. example.com. MX 20 new-mail.com.Wait for propagation (1-4 hours)
Swap priorities
example.com. MX 20 old-mail.com. example.com. MX 10 new-mail.com.Monitor both servers
Remove old MX (after 48 hours)
example.com. MX 10 new-mail.com.
Conclusion
MX records are critical for email delivery. Proper configuration ensures:
- Reliable email reception
- High availability (redundancy)
- Fast delivery
- Professional email setup
Key points:
- Use multiple MX records for redundancy
- Set priorities correctly (lower = higher priority)
- Point MX to A records, not CNAMEs or IPs
- Test thoroughly after changes
- Monitor delivery continuously
Check your MX configuration: Free MX Lookup Tool
Complete Email Setup: