MX record
Learn what a DNS MX record is, how it directs email to the correct mail servers using priorities, common setups (Google Workspace, Microsoft 365, custom), lookup methods, and troubleshooting tips.
What Is an MX Record in DNS?
TL;DR
An MX record (Mail Exchange) tells other mail servers where to deliver email for your domain (e.g., [email protected]).
It points to one or more mail server hostnames with a priority number — lower number = higher priority (tried first).
Multiple MX records provide redundancy and failover.
How MX Records Work
- Sender's mail server queries
example.comfor MX records. - It receives a list of mail servers sorted by priority (lowest number first).
- It tries the highest-priority server (lowest number).
- If that fails (down, unreachable), it tries the next, and so on.
- Same-priority servers are tried in random order.
The target hostname in an MX record must have its own A or AAAA record pointing to the actual mail server IP.
Common Use Cases
- Primary + backup mail servers: main server (low priority number) + failover
- Third-party email hosting: Google Workspace, Microsoft 365, Zoho, ProtonMail, etc.
- Load balancing email: multiple servers with same or close priorities
- Custom/self-hosted email: pointing to your own Postfix, Exchange, or mail server
- Provider migration: add new MX records before removing old ones
How to Lookup MX Records
dig example.com MXnslookup -type=MX example.comRecord Format
NAME TTL CLASS TYPE PRIORITY VALUE
example.com. 3600 IN MX 10 mail.example.com.- PRIORITY: 0–65535 (lower = higher priority)
- VALUE: Hostname of the mail server (FQDN with trailing dot recommended)
- Multiple records allowed (different priorities)
Valid Examples
Basic custom setup
example.com. MX 10 mail.example.com.
mail.example.com. A 192.0.2.1With backup
example.com. MX 10 primary-mail.example.com.
example.com. MX 20 backup-mail.example.com.Google Workspace (typical)
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.Microsoft 365
example.com. MX 0 example-com.mail.protection.outlook.com.MX vs Other Record Types
| Feature | MX | A / AAAA | CNAME |
|---|---|---|---|
| Purpose | Direct email delivery | IP address mapping | Domain alias |
| Priority | Yes (lower = better) | No | No |
| Multiple allowed | Yes | Yes | No |
| Points to | Domain name | IP address | Domain name |
| Required for email | Yes | Indirect (via MX target) | No |
→ See also: A Record, TXT Record (for SPF/DKIM/DMARC)
Frequently Asked Questions
What does the priority number mean?
Can I have multiple MX records?
Do MX records have to point inside my domain?
What happens without MX records?
Can MX point to a CNAME?
References
Related: A Record · TXT Record · DNS Basics