MX Record (Mail Exchange)

DNS Record Types
A DNS record that specifies which mail servers should receive email for a domain, enabling email delivery.
← Back to Glossary

What is an MX Record?

An MX (Mail Exchange) record is a DNS record type that specifies which mail servers are responsible for receiving email on behalf of a domain. When someone sends email to user@example.com, the sending mail server looks up MX records for example.com to find where to deliver the message.

How MX Records Work

The email delivery process:

1. Sender composes email to user@example.com

2. Sender's server queries DNS for example.com MX records

3. DNS returns one or more MX records with priorities

4. Sender connects to the highest-priority mail server

5. If unavailable, sender tries the next priority server

6. Email delivered or queued for retry

MX Record Format

example.com.    IN    MX    10    mail.example.com.

example.com. IN MX 20 mail-backup.example.com.

Components:

Priority Numbers

Priority determines the order servers are tried:

Lower numbers = higher priority. Many setups use increments of 10 to allow inserting servers later.

Common MX Configurations

Self-Hosted Email

@    IN    MX    10    mail.example.com.

mail IN A 203.0.113.50

Google Workspace

@    IN    MX    1     aspmx.l.google.com.

@ IN MX 5 alt1.aspmx.l.google.com.

@ IN MX 5 alt2.aspmx.l.google.com.

@ IN MX 10 alt3.aspmx.l.google.com.

@ IN MX 10 alt4.aspmx.l.google.com.

Microsoft 365

@    IN    MX    0     example-com.mail.protection.outlook.com.

Zoho Mail

@    IN    MX    10    mx.zoho.com.

@ IN MX 20 mx2.zoho.com.

@ IN MX 50 mx3.zoho.com.

MX Record Requirements

Target Must Be a Hostname

MX records must point to hostnames, not IP addresses:

# Correct

@ IN MX 10 mail.example.com.

# Incorrect - won't work

@ IN MX 10 203.0.113.50

Target Needs A/AAAA Record

The mail server hostname must resolve to an IP:

@      IN    MX    10    mail.example.com.

mail IN A 203.0.113.50

No CNAME Targets

MX records should not point to CNAME records (RFC 2181):

# Avoid this

mail IN CNAME host.provider.com.

@ IN MX 10 mail.example.com.

Checking MX Records

Using dig:
dig example.com MX

; ANSWER SECTION:

example.com. 300 IN MX 10 mail.example.com.

example.com. 300 IN MX 20 mail-backup.example.com.

Using DomScan:
curl "https://domscan.net/v1/health?domain=example.com"

# Returns hasMX: true/false in DNS details

MX Records and Email Security

MX records work alongside other email authentication records:

RecordPurpose
MXRoute incoming email
SPFAuthorize sending servers
DKIMSign outgoing messages
DMARCPolicy enforcement

All four should be configured for proper email operation and deliverability.

Troubleshooting MX Issues

No MX Records

If no MX records exist, some servers fall back to A record lookup—but this is unreliable. Always configure explicit MX records.

Wrong Priority

If a backup server has lower priority (higher number) than intended, it won't receive email unless the primary fails.

Hostname Resolution Failure

If the MX target hostname doesn't resolve, email delivery fails. Verify A records exist for mail server hostnames.

TTL Considerations

When migrating email providers, lower MX TTLs beforehand to speed up propagation, then restore normal TTLs after migration.

Best Practices

1. Always have MX records: Don't rely on A record fallback

2. Configure backup servers: Use multiple MX records with different priorities

3. Verify target resolution: Ensure mail server hostnames have A records

4. Implement email authentication: Add SPF, DKIM, and DMARC alongside MX

5. Monitor email delivery: Use tools to test MX configuration

Put This Knowledge to Work

Use DomScan's API to check domain availability, health, and more.