MX Records: How Email Routing Works
MX (Mail Exchange) records are the foundation of email delivery, telling the world which servers handle email for your domain. This guide explains how MX records work, common configurations, and best practices.
What are MX Records?
MX records are DNS records that specify which mail servers are responsible for receiving email on behalf of a domain. When someone sends an email to user@yourdomain.com, their email server looks up your domain's MX records to find where to deliver the message.
Without MX records, email servers wouldn't know where to send messages destined for your domain, and your emails would bounce or never arrive.
How MX Records Work
When an email is sent to your domain, the sending mail server follows these steps:
- DNS Lookup - The sending server queries DNS for MX records of the recipient domain
- Priority Selection - It reads the priority values and selects the server with the lowest number (highest priority)
- Connection Attempt - It attempts to connect to the primary mail server
- Fallback if Needed - If the primary server is unavailable, it tries the next server in priority order
- Email Delivery - Once connected, the email is transferred via SMTP
Priority Values Explained
Each MX record has a priority value (also called preference). Lower numbers indicate higher priority. The sending server always tries the lowest priority number first.
example.com. MX 10 mail1.example.com. ; Primary (tried first)
example.com. MX 20 mail2.example.com. ; Secondary (backup)
example.com. MX 30 mail3.example.com. ; Tertiary (last resort)If multiple servers have the same priority, the sending server typically distributes load randomly between them (round-robin).
MX Record Syntax
An MX record consists of several components:
Host/Name Type Priority Mail Server TTL
@ MX 10 mail.example.com. 3600| Component | Description |
|---|---|
| Host/Name | The domain this record applies to (@ means the root domain) |
| Type | Always "MX" for mail exchange records |
| Priority | A number (0-65535) indicating preference; lower = higher priority |
| Mail Server | The hostname of the mail server (must be a valid A or AAAA record) |
| TTL | Time-to-live in seconds; how long DNS resolvers cache this record |
MX records must point to a hostname (A/AAAA record), never directly to an IP address. The hostname must end with a period (.) in zone files to indicate a fully qualified domain name.
Common MX Record Setups
Google Workspace
Google Workspace uses multiple MX records for redundancy:
@ MX 1 ASPMX.L.GOOGLE.COM.
@ MX 5 ALT1.ASPMX.L.GOOGLE.COM.
@ MX 5 ALT2.ASPMX.L.GOOGLE.COM.
@ MX 10 ALT3.ASPMX.L.GOOGLE.COM.
@ MX 10 ALT4.ASPMX.L.GOOGLE.COM.Microsoft 365
Microsoft 365 typically uses a single MX record:
@ MX 0 yourdomain-com.mail.protection.outlook.com.Replace "yourdomain-com" with your domain name (dots replaced by dashes).
Zoho Mail
@ MX 10 mx.zoho.com.
@ MX 20 mx2.zoho.com.
@ MX 50 mx3.zoho.com.ProtonMail
@ MX 10 mail.protonmail.ch.
@ MX 20 mailsec.protonmail.ch.Self-Hosted Mail Server
@ MX 10 mail.yourdomain.com.
@ MX 20 backup.yourdomain.com.Best Practices
Always have at least two MX records with different priorities for redundancy. If your primary server goes down, email will still be delivered to your backup.
Leave gaps between priority values (e.g., 10, 20, 30) so you can insert new servers later without reconfiguring existing records.
Use a TTL of 3600 seconds (1 hour) for normal operations. Lower it temporarily before making changes to speed up propagation.
Every mail server hostname in your MX records must have a corresponding A (IPv4) and/or AAAA (IPv6) record.
MX records must point to hostnames, not IP addresses. This is a requirement of the RFC specification and improves flexibility.
After updating MX records, test email delivery to ensure everything works correctly. DNS changes can take time to propagate.
Troubleshooting Common MX Issues
No MX Records Found
If your domain has no MX records, email will attempt to fall back to the A record (direct delivery), but most modern mail servers won't do this. Always ensure MX records are configured.
# Check MX records using dig
dig MX yourdomain.com
# Or using nslookup
nslookup -type=mx yourdomain.comMX Points to IP Instead of Hostname
MX records cannot point directly to IP addresses. If you see this error, update the MX record to point to a hostname that has an A record.
Missing A Record for Mail Server
If your MX record points to a hostname that doesn't have an A record, email delivery will fail. Verify the A record exists:
# Verify A record exists for mail server
dig A mail.yourdomain.comDNS Propagation Delays
After changing MX records, it can take up to 48 hours for changes to propagate globally. During this time:
- Some emails may go to old servers
- Some emails may go to new servers
- Test from multiple locations/networks
Firewall or Port Blocking
Even with correct MX records, email won't work if port 25 (SMTP) is blocked on your mail server. Verify connectivity:
# Test SMTP connectivity
telnet mail.yourdomain.com 25
# Or using nc
nc -zv mail.yourdomain.com 25Summary
- 1.MX records tell other mail servers where to deliver email for your domain
- 2.Lower priority numbers mean higher preference (10 is tried before 20)
- 3.Always configure multiple MX records for redundancy and reliability
- 4.MX records must point to hostnames with valid A records, never IP addresses
- 5.Test your configuration after making changes and allow time for DNS propagation
Resources
Check Your MX Records
Use our scanner to verify your domain's MX records are configured correctly and your email infrastructure is properly set up.
Scan Your Domain