What Is an MX Record? Complete Guide to Email DNS Configuration

· Unified DNS Team · 8 min read

What Is an MX Record?

An MX record (Mail Exchanger record) specifies which mail servers accept email for your domain. When someone sends an email to user@example.com, their mail server looks up the MX records for example.com to find where to deliver the message.

The Basics

Example

; Microsoft 365 mail servers
example.com.    3600    IN    MX    0 example-com.mail.protection.outlook.com.

; Google Workspace mail servers
example.com.    3600    IN    MX    1 aspmx.l.google.com.
example.com.    3600    IN    MX    5 alt1.aspmx.l.google.com.
example.com.    3600    IN    MX    5 alt2.aspmx.l.google.com.
example.com.    3600    IN    MX    10 alt3.aspmx.l.google.com.
example.com.    3600    IN    MX    10 alt4.aspmx.l.google.com.

How MX Records Work

When an email is sent, the sending server follows this process:

  1. Sender composes email to user@example.com
  2. Sender's server queries DNS for MX records of example.com
  3. DNS returns MX records with priorities
  4. Server connects to lowest priority mail server first
  5. Email is delivered (or server tries next MX on failure)

MX Record Structure

ComponentExampleDescription
**Name**@Usually the root domain
**TTL**3600Time To Live in seconds
**Priority**10Lower number = higher priority
**Target**mail.example.com.Mail server hostname

The Lookup Process

Email to: user@example.com
         ↓
DNS Query: "MX records for example.com?"
         ↓
Response: 10 mail.example.com.
          20 backup.example.com.
         ↓
Connect to: mail.example.com (priority 10)
         ↓
If failed: Try backup.example.com (priority 20)

Understanding MX Priority

The priority value determines the order in which mail servers are tried. Lower numbers have higher priority.

Single Mail Server

For most small businesses with one mail provider:

example.com.    3600    IN    MX    0 mail.example.com.

Multiple Servers with Failover

For redundancy, configure backup mail servers:

; Primary server - tried first
example.com.    3600    IN    MX    10 mail1.example.com.

; Backup server - tried if primary fails
example.com.    3600    IN    MX    20 mail2.example.com.

; Emergency backup
example.com.    3600    IN    MX    30 mail3.example.com.

Load Balancing with Equal Priorities

When multiple MX records have the same priority, mail servers randomly choose between them:

; Traffic distributed across both servers
example.com.    3600    IN    MX    10 mail1.example.com.
example.com.    3600    IN    MX    10 mail2.example.com.

Common Email Configurations

Microsoft 365

; MX record
example.com.    3600    IN    MX    0 example-com.mail.protection.outlook.com.

; Autodiscover for Outlook clients
autodiscover.example.com.    3600    IN    CNAME    autodiscover.outlook.com.

; SPF record
example.com.    3600    IN    TXT    "v=spf1 include:spf.protection.outlook.com -all"

; DKIM selectors
selector1._domainkey.example.com.    3600    IN    CNAME    selector1-example-com._domainkey.example.onmicrosoft.com.
selector2._domainkey.example.com.    3600    IN    CNAME    selector2-example-com._domainkey.example.onmicrosoft.com.

Google Workspace

; MX records (all 5 required)
example.com.    3600    IN    MX    1 aspmx.l.google.com.
example.com.    3600    IN    MX    5 alt1.aspmx.l.google.com.
example.com.    3600    IN    MX    5 alt2.aspmx.l.google.com.
example.com.    3600    IN    MX    10 alt3.aspmx.l.google.com.
example.com.    3600    IN    MX    10 alt4.aspmx.l.google.com.

; SPF record
example.com.    3600    IN    TXT    "v=spf1 include:_spf.google.com ~all"

Zoho Mail

; MX records
example.com.    3600    IN    MX    10 mx.zoho.com.
example.com.    3600    IN    MX    20 mx2.zoho.com.
example.com.    3600    IN    MX    50 mx3.zoho.com.

; SPF record
example.com.    3600    IN    TXT    "v=spf1 include:zoho.com ~all"

Self-Hosted Mail Server

; Primary mail server
example.com.    3600    IN    MX    10 mail.example.com.

; A record for mail server
mail.example.com.    3600    IN    A    198.51.100.25

; PTR record (set on IP owner's side)
25.100.51.198.in-addr.arpa.    3600    IN    PTR    mail.example.com.

; SPF record
example.com.    3600    IN    TXT    "v=spf1 ip4:198.51.100.25 -all"

Best Practices for MSPs

1. Always Have Backup MX Records

Even with cloud email, consider backup MX servers that queue mail if the primary is temporarily unavailable. Many email security gateways provide this.

2. Keep Priority Numbers Spaced Apart

Use increments of 10 to leave room for inserting servers later:

; Good - room for future changes
example.com.    MX    10 primary.mail.com.
example.com.    MX    20 secondary.mail.com.

; Avoid - no room to insert
example.com.    MX    1 primary.mail.com.
example.com.    MX    2 secondary.mail.com.

3. Verify MX Target Has Valid A Record

The MX target must resolve to an IP address:

# Check MX record
dig example.com MX

# Verify target resolves
dig mail.example.com A

4. Don't Point MX to CNAME

Per RFC 2181, MX records should point to a hostname with an A record, not a CNAME:

; Correct
example.com.        MX    10 mail.example.com.
mail.example.com.   A     198.51.100.25

; Incorrect - MX pointing to CNAME
example.com.        MX    10 mail.example.com.
mail.example.com.   CNAME mailserver.provider.com.

5. Configure Complementary Records

MX records alone aren't enough for reliable email. Always configure:

6. Document Everything

Track for each domain:

Troubleshooting Email Delivery

Email Not Being Received

Check MX records exist:

dig example.com MX

Verify MX target resolves:

dig mail.example.com A

Test mail server connection:

telnet mail.example.com 25

Email Going to Spam

Usually an authentication issue, not MX:

Delayed Email Delivery

Check MX priority:

Check DNS propagation:

# Query multiple DNS servers
dig @8.8.8.8 example.com MX
dig @1.1.1.1 example.com MX

Testing Email Flow

Use online tools to verify your configuration:

Frequently Asked Questions

Can I have MX records for subdomains?

Yes! Each subdomain can have its own MX records:

example.com.           MX    10 mail.example.com.
marketing.example.com. MX    10 mail.marketingplatform.com.

What happens if all MX servers are down?

Sending servers will queue the email and retry according to their configuration (typically for up to 5 days). If all attempts fail, the sender receives a bounce message.

Do I need an MX record if I only send email, not receive?

Technically no, but it's strongly recommended. Many spam filters check for MX records when validating the sender's domain. A null MX record can indicate "this domain doesn't accept email."

What's a null MX record?

RFC 7505 defines a null MX record to explicitly state a domain doesn't accept email:

example.com.    3600    IN    MX    0 .

Should MX priority be 0 or higher?

Either works. Priority 0 is perfectly valid and is the highest priority. Many administrators use 10 as the starting point to leave room for lower priorities if needed.

Can I use an IP address in an MX record?

No, MX records must point to a hostname, not an IP address. The hostname must then have an A or AAAA record.


Get Started with Unified DNS

Email configuration is critical for business communication. Unified DNS lets you view, modify, audit, and backup MX records and all related email DNS (SPF, DKIM, DMARC) across all your clients — with automated syncing to Hudu for documentation and automated backups for peace of mind.

Unified DNS is live — try it free for a month with code FREETRIAL2026 at billing setup. No commitment. Or request a demo for a walkthrough.