Managing MX Record Priorities

MX record priorities determine the order in which mail servers are contacted for email delivery. Understanding how to monitor priorities ensures your email infrastructure maintains proper routing configuration.

Understanding MX Priorities

MX records consist of two parts:

  1. Priority (preference value): Lower numbers indicate higher priority
  2. Hostname: The mail server address

Example MX records:

10 mx1.mail-provider.com    ← Primary (highest priority)
20 mx2.mail-provider.com    ← Secondary
30 mx3.mail-provider.com    ← Backup (lowest priority)

Email servers attempt delivery to the lowest priority number first, falling back to higher numbers if delivery fails.

Monitoring Without Priorities

By default, if you don't specify priorities, DNSRadar accepts any priority value:

curl -X POST https://api.dnsradar.dev/monitors \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "domain": "piedpiper.com",
  "record_type": "MX",
  "expected_value": [
    "mx1.mail-provider.com",
    "mx2.mail-provider.com"
  ]
}'

This configuration matches ANY of these:

10 mx1.mail-provider.com, 20 mx2.mail-provider.com  ✅
5 mx1.mail-provider.com, 10 mx2.mail-provider.com   ✅
100 mx1.mail-provider.com, 100 mx2.mail-provider.com ✅
50 mx1.mail-provider.com, 40 mx2.mail-provider.com  ✅

Monitoring With Priorities

To enforce specific priorities, include them in your expected values using the format "<priority> <hostname>":

curl -X POST https://api.dnsradar.dev/monitors \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "domain": "piedpiper.com",
  "record_type": "MX",
  "expected_value": [
    "10 mx1.mail-provider.com",
    "20 mx2.mail-provider.com"
  ]
}'

This configuration ONLY matches:

10 mx1.mail-provider.com, 20 mx2.mail-provider.com  ✅

These would trigger MISMATCH:

5 mx1.mail-provider.com, 20 mx2.mail-provider.com   ❌ Wrong priority for mx1
10 mx1.mail-provider.com, 30 mx2.mail-provider.com  ❌ Wrong priority for mx2
20 mx1.mail-provider.com, 10 mx2.mail-provider.com  ❌ Priorities reversed

Priority Format Rules

Valid Formats

{
  "expected_value": [
    "10 mx1.service.com",
    "20 mx2.service.com",
    "30 mx3.service.com"
  ]
}

Invalid Formats

{
  "expected_value": [
    "mx1.service.com 10",     // ❌ Priority must be first
    "10mx1.service.com",      // ❌ Missing space
    "10  mx1.service.com",    // ❌ Multiple spaces
    "10. mx1.service.com"     // ❌ Invalid priority format
  ]
}

Consistency Requirements

Invalid (Mixed)

{
  "expected_value": [
    "10 mx1.service.com",  // With priority
    "mx2.service.com"      // Without priority
  ]
  // ❌ INVALID: Inconsistent format
}

Valid (Consistent)

// All without priorities ✅
{
  "expected_value": [
    "mx1.service.com",
    "mx2.service.com"
  ]
}

// All with priorities ✅
{
  "expected_value": [
    "10 mx1.service.com",
    "20 mx2.service.com"
  ]
}

Priorities with Flexible Matching

You can combine priority enforcement with flexible matching to allow additional mail servers:

curl -X POST https://api.dnsradar.dev/monitors \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "domain": "piedpiper.com",
  "record_type": "MX",
  "expected_value": [
    "10 mx1.service.com",
    "20 mx2.service.com"
  ],
  "is_exact_match": false
}'

This configuration:

  • ✅ Enforces specific priorities for your mail servers
  • ✅ Allows customers to add additional mail servers at any priority
  • ❌ Triggers MISMATCH if your servers' priorities change

Example valid configurations:

10 mx1.service.com, 20 mx2.service.com                           ✅
10 mx1.service.com, 20 mx2.service.com, 30 mx.backup.com        ✅
10 mx1.service.com, 15 mx.other.com, 20 mx2.service.com         ✅
5 mx.customer.com, 10 mx1.service.com, 20 mx2.service.com       ✅

When Priorities Don't Matter

Skip priority monitoring when:

  1. Service Provider Changes: Email providers may adjust priorities for optimization
  2. Customer Flexibility: Customers should control their mail routing preferences
  3. Equal Priority Load Balancing: When multiple servers share the same priority
  4. Backup Server Addition: Customers adding their own backup servers

Next Steps