Skip to content
Back to Blog
DNS & Networking10 min read

MX Record Setup: Production Best Practices for 2026

Master production-grade MX record configuration with proven patterns, priority strategies, and the common anti-patterns that break email delivery at scale.

Written by Abdul AbrorTechnical Hosting Support Engineer
MX Record Setup: Production Best Practices for 2026
On this page

MX records are the foundation of email delivery, yet they're frequently misconfigured in ways that cause intermittent failures, delivery delays, and blacklisting. This guide covers production-grade MX record setup patterns I've validated across hundreds of hosting environments, along with the anti-patterns that create problems you won't notice until email stops working.

The Core Principles

Production MX record configuration rests on three principles: explicit priority ordering, meaningful redundancy, and fail-fast behavior. These principles guide every decision in this article.

Priority ordering ensures mail servers are tried in the sequence you intend. Meaningful redundancy means backup MX hosts that actually work, not placeholder records. Fail-fast behavior means misconfigured records produce immediate errors rather than silent delays.

Priority Assignment Strategy

MX priority values determine delivery order. Lower numbers are tried first. The specific numbers matter less than the gaps between them.

The Right Pattern

Use priority values that leave room for future additions:

example.com.  IN MX 10 mail1.example.com.
example.com.  IN MX 20 mail2.example.com.
example.com.  IN MX 30 mail3.example.com.

This spacing allows you to insert a new primary with priority 5, or add backup hosts at 15 or 25, without renumbering everything.

The Anti-Pattern: Sequential Priorities

Avoid consecutive values:

# Anti-pattern
example.com.  IN MX 1 mail1.example.com.
example.com.  IN MX 2 mail2.example.com.
example.com.  IN MX 3 mail3.example.com.

This leaves no room for adjustments. Adding a new primary requires renumbering all existing records, which increases the risk of configuration errors during maintenance windows.

Priority Value Ranges

Most production environments use priorities between 0 and 50. Technically valid priorities range from 0 to 65535, but values above 100 are rarely needed and may confuse monitoring tools that assume typical ranges.

Use priority 0 only when you have a single MX record and want to make that explicit. For multi-host setups, start at 10.

Redundancy Architecture

Backup MX hosts are worthless if they can't actually receive and process mail. Real redundancy requires independent infrastructure.

Geographic Distribution

Place primary and backup MX hosts in different data centers or availability zones:

example.com.  IN MX 10 mail-us-east.example.com.
example.com.  IN MX 20 mail-eu-west.example.com.

This protects against regional network failures, power outages, and DDoS attacks targeting a single location. The backup host should have its own network path, power supply, and upstream providers.

The Anti-Pattern: Same-Subnet Backups

Backup MX records pointing to hosts in the same subnet provide no real redundancy:

# Anti-pattern
example.com.  IN MX 10 mail1.example.com.  # 192.0.2.10
example.com.  IN MX 20 mail2.example.com.  # 192.0.2.11

If the subnet becomes unreachable, both hosts fail simultaneously. If the data center loses power, both hosts go offline. This configuration gives a false sense of redundancy.

Queue Behavior on Backup Hosts

Backup MX hosts should either queue messages for the primary or deliver them to the same mail store. Avoid configurations where backup hosts silently discard mail or require manual intervention to release queued messages.

If your backup host queues messages, set reasonable retry intervals and maximum queue lifetime. Messages should attempt delivery to the primary every 15-30 minutes and expire after 4-5 days, matching typical SMTP retry behavior.

Hostname Requirements

MX records must point to hostnames with A or AAAA records, never to IP addresses, CNAMEs, or other record types.

The Correct Pattern

example.com.       IN MX 10 mail.example.com.
mail.example.com.  IN A     192.0.2.10

The MX record contains a hostname. That hostname resolves to an IP address via an A record.

The Anti-Pattern: CNAME Targets

# Anti-pattern - prohibited by RFC 5321
example.com.       IN MX 10 mail.example.com.
mail.example.com.  IN CNAME smtp.vendor.com.

MX records cannot point to CNAMEs. This violates the SMTP specification and causes unpredictable behavior. Some mail servers will follow the CNAME anyway, others will reject the configuration, and DNS resolvers may cache the CNAME in ways that break delivery.

If you use a third-party email service, create A records that point to their IP addresses rather than CNAME aliases.

TTL Strategy

MX record TTL (time to live) controls how long resolvers cache your records. Production TTL choices balance change velocity against query load.

Standard TTL Values

For stable production email infrastructure, use a TTL of 3600 seconds (1 hour) or 7200 seconds (2 hours):

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

This allows changes to propagate within hours while reducing DNS query volume.

Pre-Migration TTL Reduction

Before migrating email providers or changing MX records, reduce TTL to 300 seconds (5 minutes) at least 24 hours in advance:

# Day 1: Lower TTL
example.com.  300  IN MX 10 old-mail.example.com.

# Day 2: Update MX records
example.com.  300  IN MX 10 new-mail.example.com.

# Day 3: Restore normal TTL
example.com.  3600  IN MX 10 new-mail.example.com.

This ensures cached records expire quickly, minimizing the window where mail is delivered to old servers.

The Anti-Pattern: Permanent Low TTL

Some administrators set TTL to 60 or 300 seconds permanently, assuming faster updates are always better. This increases DNS query volume without benefit and can trigger rate limiting on some DNS providers.

Low TTL is a temporary tool for migrations, not a permanent configuration.

Priority Tie Handling

When multiple MX records share the same priority, sending mail servers choose randomly. This behavior is intentional load distribution, not a configuration error.

Intentional Load Balancing

example.com.  IN MX 10 mail1.example.com.
example.com.  IN MX 10 mail2.example.com.
example.com.  IN MX 10 mail3.example.com.

This distributes incoming mail across three hosts with equal priority. Sending servers select one randomly, effectively load balancing.

Use this pattern when all hosts have identical capacity and you want even distribution. Do not mix high-capacity and low-capacity hosts at the same priority.

The Anti-Pattern: Unintentional Ties

Accidental priority ties create confusion:

# Anti-pattern
example.com.  IN MX 10 mail-primary.example.com.
example.com.  IN MX 10 mail-backup.example.com.  # Typo: should be 20

If priority 10 was a typo and mail-backup is actually a lower-capacity host, you'll see overload on the backup during normal operation. Monitor your MX records and validate priority values match your intent.

Reverse DNS and Forward Confirmation

MX record hostnames should have matching PTR records (reverse DNS). This isn't technically required for MX records themselves, but mail servers you send to will check reverse DNS on your SMTP connection.

Forward-Confirmed Reverse DNS

Configure both directions:

# Forward
mail.example.com.  IN A   192.0.2.10

# Reverse (managed in your IP block)
10.2.0.192.in-addr.arpa.  IN PTR mail.example.com.

When an outbound mail server connects from 192.0.2.10, the receiving server looks up the PTR record and finds mail.example.com. It then looks up mail.example.com and verifies it resolves to 192.0.2.10. This forward-confirmed reverse DNS (FCrDNS) check is used by spam filters.

The Anti-Pattern: Generic PTR Records

Many hosting providers assign generic PTR records:

# Anti-pattern
10.2.0.192.in-addr.arpa.  IN PTR vps-192-0-2-10.hosting.example.

This fails FCrDNS because mail.example.com doesn't resolve to the same IP as vps-192-0-2-10.hosting.example. Request custom PTR records from your hosting provider or IP space administrator.

Zero-MX Pattern for Non-Email Domains

Domains that never receive email should publish a null MX record rather than no MX record at all.

Explicit No-Email Declaration

noemail.example.  IN MX 0 .

This tells sending mail servers not to attempt delivery. The priority 0 and target "." indicate this domain does not accept mail. Sending servers can immediately reject messages instead of attempting fallback delivery to A records.

Why This Matters

Without an MX record, RFC 5321 requires mail servers to attempt delivery to the domain's A record. If noemail.example has an A record pointing to a web server, mail servers will try connecting to port 25 on that web server, creating connection attempts that fail slowly.

The null MX pattern prevents this wasted effort.

Testing and Validation

After configuring MX records, validate them from multiple perspectives.

DNS Query Validation

Query your MX records from an external resolver:

dig +short MX example.com @8.8.8.8

Expected output:

10 mail1.example.com.
20 mail2.example.com.

The priority values should appear first, followed by the hostnames. Verify the hostnames resolve to IP addresses:

dig +short A mail1.example.com @8.8.8.8

SMTP Connection Testing

Test actual mail delivery to each MX host:

telnet mail1.example.com 25

You should see an SMTP banner. Verify each MX host responds and identifies itself correctly. Test backup hosts by temporarily removing the primary from DNS or firewalling port 25.

Third-Party Validation Tools

Use MX lookup tools from multiple geographic locations to check for propagation issues. Different DNS resolvers may cache records at different times during updates.

Monitoring and Alerting

Production MX records require active monitoring.

DNS Monitoring

Monitor MX record resolution from multiple locations. Alert on:

  • MX record disappearance or unexpected changes
  • MX hostnames that stop resolving to IP addresses
  • TTL changes outside maintenance windows
  • Priority value changes

Connectivity Monitoring

Monitor SMTP port connectivity to all MX hosts:

echo "QUIT" | nc -w 5 mail1.example.com 25

Alert if any MX host becomes unreachable or stops responding on port 25.

Queue Depth Monitoring

Monitor mail queue depth on backup MX hosts. Sustained queue growth indicates the primary is unreachable or the backup isn't releasing messages properly.

SPF and DKIM Coordination

MX records define where you receive mail. SPF and DKIM define where you send mail from. These must align.

Include MX Hosts in SPF

If your MX hosts also send outbound mail, include them in your SPF record:

example.com.  IN TXT "v=spf1 mx ip4:192.0.2.10 -all"

The "mx" mechanism authorizes the hosts listed in your MX records to send mail. This is convenient but creates a dependency: changing MX records affects SPF evaluation.

For production environments with separate inbound and outbound infrastructure, list outbound hosts explicitly rather than using the "mx" mechanism.

DKIM Signing on All Outbound Paths

Ensure every host that sends mail can sign messages with valid DKIM keys. This includes primary mail servers, backup MX hosts that relay queued messages, and any automated systems that send transactional email.

Common Production Scenarios

Single Server Setup

Small deployments often run mail on a single host. Use a single MX record:

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

This is honest about your infrastructure. Adding a fake backup MX that doesn't actually work is worse than admitting you have a single point of failure.

Hybrid Cloud Setup

Many organizations run primary mail on-premises with cloud backup:

example.com.  IN MX 10 mail.onprem.example.com.
example.com.  IN MX 20 mail.cloud.example.com.

Ensure the cloud backup can queue messages and relay them to the primary when it recovers. Test failover by blocking the primary's IP and verifying mail flows through the cloud backup.

Third-Party Email Service

When using providers like Google Workspace or Microsoft 365, use the exact MX records they specify. These typically include multiple hosts with specific priorities:

example.com.  IN MX 1  aspmx.l.google.com.
example.com.  IN MX 5  alt1.aspmx.l.google.com.
example.com.  IN MX 5  alt2.aspmx.l.google.com.
example.com.  IN MX 10 alt3.aspmx.l.google.com.
example.com.  IN MX 10 alt4.aspmx.l.google.com.

Do not modify these priorities or hostnames. The provider has configured their infrastructure to expect this specific pattern.

Migration Procedure

Changing MX records requires careful sequencing to avoid losing mail.

Pre-Migration Checklist

  1. Lower TTL on existing MX records 24 hours before migration
  2. Configure new mail servers and verify they receive test messages
  3. Set up mail forwarding from new servers to old servers
  4. Update MX records to point to new servers
  5. Monitor queue depth on old servers
  6. After 48 hours, disable forwarding
  7. After one week, decomission old servers

The forwarding step ensures any mail delivered to old servers during the TTL window gets routed to the new infrastructure. Monitor both systems during the overlap period.

Conclusion

Production MX record configuration is about intentional design rather than clever tricks. Use priority spacing that allows future changes, deploy real redundancy across independent infrastructure, maintain proper forward and reverse DNS, and monitor continuously. Avoid the anti-patterns that create silent failures: same-subnet backups, CNAME targets, and permanent low TTL values. Test your configuration from outside your network, validate that backup hosts actually work, and maintain an audit trail of changes. Email infrastructure is critical: approach MX record configuration with the same rigor you apply to other production systems.

FAQ

Should MX priority start at 0, 1, or 10?

Start at 10 for multi-host setups. This leaves room below for future additions. Use 0 only for single-host configurations where you want to emphasize there's exactly one MX record.

How many MX records do I need?

Two is the practical minimum for redundancy. More than five is rarely useful unless you're operating a large distributed mail infrastructure. Three is the sweet spot for most production environments: one primary, one backup in a different location, and one additional backup for extra redundancy.

Can I use a load balancer IP as an MX target?

Yes, as long as the MX record points to a hostname with an A record, and that A record points to the load balancer IP. The hostname is required; you cannot point an MX record directly to an IP address.

What happens if all my MX hosts are down?

Sending mail servers will retry delivery for several days (typically 4-5 days) before bouncing messages. This is why monitoring and redundancy matter: you have a grace period, but it's measured in days, not weeks.

Do MX records affect outbound mail?

No. MX records only control where others send mail to your domain. Outbound mail delivery is controlled by your SMTP server configuration, SPF records, and DKIM signing.

Should backup MX hosts have lower priority numbers?

No. Lower priority numbers are tried first. Your primary server should have the lowest number (like 10), and backup servers should have higher numbers (like 20, 30).