What is an MX record? Mail servers, priority numbers and fallbacks

By TechCompare · Updated · How we check

Lower numbers win. A record of 10 mx1.example.com is tried before 20 mx2.example.com, and records with the same number share the load between them.

An MX record tells other mail servers where to deliver mail for a domain. Each one has two parts: a priority number and the hostname of a mail server. Senders try the lowest number first and only move up the list when that server doesn't answer. Without any MX record, a sender falls back to the domain's own address, which is rarely what you want.

Topic
MX records
Mail routing
Category
Record types
What each record does

How this is calculated

The priority (RFC 5321 calls it the preference) is a number from 0 to 65535. Only the order matters, so 10 and 20 behave the same as 1 and 2. When several records share the lowest number, senders pick among them at random, which spreads the mail out. A higher number is a backup that takes mail when the main servers can't.

The target has to be a hostname with its own A or AAAA record. It can't be an IP address, and RFC 2181 says it must not be an alias (CNAME). Plenty of servers follow an alias anyway, but some refuse, so mail can bounce for a few senders and not for others.

A domain with no MX record isn't cut off from mail. RFC 5321 tells senders to deliver to the domain's own A or AAAA address instead. To say a domain takes no mail at all, publish a null MX: one record with priority 0 and a target of a single dot (RFC 7505). Senders then bounce mail right away instead of retrying for days.

The DNS Lookup lists MX records by priority. Pick a few resolvers to compare, and a move to a new mail host shows up for every resolver once it has spread.

Verdict

Copy the MX records your mail provider gives you exactly, priorities included, and remove the old provider's records on the day you switch. Point each one at a hostname, never at an IP or a CNAME. If a domain never sends or receives mail, add a null MX next to an SPF record of v=spf1 -all, so nobody can use it for mail.

More DNS scenarios

TXT records
The free text record that holds verification codes, SPF, DKIM keys and DMARC policies.
View details
SPF vs DKIM vs DMARC
SPF checks the sending server, DKIM checks the message, and DMARC ties both to the From address.
View details
CNAME vs A record
An A record points a name at an address. A CNAME points it at another name, with rules that trip people up.
View details

Frequently asked questions

What does the number in an MX record mean?
It's the priority. Senders try the server with the lowest number first and only move to a higher one when that server can't be reached. Records with the same number share the mail between them.
Can an MX record point to an IP address?
No. The value has to be a hostname, and that hostname needs its own A or AAAA record. Point the MX at a name like mail.example.com and give that name the address.
What is a null MX record?
A single MX record with priority 0 and a target of a lone dot, defined in RFC 7505. It says the domain takes no mail, so senders bounce messages right away instead of retrying.