Knowledge base

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.

Look up MX records
Enter a domain name to lookup MX records

Enter the domain name you want to lookup

How MX Records Work

  1. Sender's mail server queries example.com for MX records.
  2. It receives a list of mail servers sorted by priority (lowest number first).
  3. It tries the highest-priority server (lowest number).
  4. If that fails (down, unreachable), it tries the next, and so on.
  5. 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 MX
nslookup -type=MX example.com

Record 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.1

With 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

FeatureMXA / AAAACNAME
PurposeDirect email deliveryIP address mappingDomain alias
PriorityYes (lower = better)NoNo
Multiple allowedYesYesNo
Points toDomain nameIP addressDomain name
Required for emailYesIndirect (via MX target)No

→ See also: A Record, TXT Record (for SPF/DKIM/DMARC)

Frequently Asked Questions

What does the priority number mean?
Lower number = higher priority. Mail servers try the lowest number first. Same-priority servers are selected randomly.
Can I have multiple MX records?
Yes, recommended for redundancy. The system automatically fails over to the next if the primary is down.
Do MX records have to point inside my domain?
No, they can point anywhere (e.g., Google's servers, Microsoft, your host).
What happens without MX records?
Some servers fall back to the domain's A record, but this is unreliable and not standards-compliant. Always set explicit MX records.
Can MX point to a CNAME?
Technically yes, but avoid it, many mail servers reject or have issues with CNAME targets for MX.

References

Related: A Record · TXT Record · DNS Basics