Chapters (12)

MX records

The short version

  • An MX record tells the world which server takes email for your domain.
  • Each MX record has a number. The lowest number is tried first.
  • Extra MX records with higher numbers act as backups.
  • An MX record must point to a name, not an IP address, and not to an alias.
  • Changing your MX records changes where new email goes.

Where should the mail go?

Someone sends an email to [email protected]. Their mail server needs to know where to deliver it.

It finds out by asking DNS for the MX records of example.com. MX is short for mail exchange. Each MX record names a server that will take mail for the domain.[1][2]

Four steps. 1: someone emails hello@example.com. 2: their server asks for example.com's MX. 3: DNS answers mail.example.com. 4: the email goes to that server.
How a sending server uses MX records to find where to deliver mail.

Notice that email does not use the A record of example.com when MX records exist.[3] Your website and your email can live with different providers. The MX records decide where mail goes.

What an MX record looks like

Here is one, written the way DNS tools show it:

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

It has two parts at the end:

  • 10 is the preference number.
  • mail.example.com is the name of the mail server.

The preference number is how you rank servers. Lower numbers are preferred.[1] People also call it the priority.

Wikipedia's article shows two MX records for one domain, both with the same number:

Wikipedia's MX record article, showing a table with two MX records for example.com, both with priority 10, pointing to onemail.example.com and twomail.example.com.
Two MX records with the same priority, from Wikipedia's article. Screenshot: Wikipedia, captured 2026-10-18.

Priorities and backups

A domain can have several MX records, each pointing at a different server. This spreads the load and gives you a backup.[2]

example.com.    3600    IN    MX    10 mail1.example.com.
example.com.    3600    IN    MX    20 mail2.example.com.

A sending server sorts the list by number, lowest first.[3] It tries mail1 first. If that fails, it moves down the list and tries mail2. It keeps going until delivery works.[3]

Incoming email goes first, by a solid arrow, to the server with number 10, mail1.example.com, marked tried first. A dashed arrow leads to number 20, mail2.example.com, marked backup. The lowest number wins and the next one is the fallback.
Lower preference numbers are tried first. Higher ones are backups.

What if two records have the same number? Then the sender picks between them at random. This shares the mail between both servers.[3]

The rules for this are in the email standard itself. Here is the part that explains how a sender finds the server:

Section 5.1 of RFC 5321, "Locating the Target Host". It explains that the lookup first looks for an MX record, and what happens if none is found.
The email standard's rules for finding a domain's mail server. Screenshot: RFC Editor, captured 2026-10-18.

Point at a name, not a number

An MX record holds a server name, not an IP address. That name then needs its own A or AAAA record. The address comes from there.[3]

The name must not be an alias. In other words, it can't have a CNAME record.[4]

So a working setup looks like this:

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

What if there is no MX record?

If a domain has no MX records at all, senders fall back. They try the domain's own address as if it were the mail server.[3]

That can be a problem if the domain's web server doesn't take email. So a domain that never receives mail can say so directly. It publishes a special null MX record. It has the number 0 and a single dot as the server name.[5]

That is exactly what example.com does. Google's online Dig tool shows its MX record:

Google Admin Toolbox Dig, with example.com entered and MX selected. One MX record is shown, with EXCHANGE set to a single dot and PREFERENCE 0.
example.com publishes a null MX: preference 0 and a dot, meaning it takes no email. Screenshot: Google Admin Toolbox, captured 2026-10-18.

The exchange is just a dot, with preference 0. In plain words: "this domain takes no email".[5]

When you change email provider

Your new email provider will give you its MX records to add. Take the old provider's MX records out at the same time.

While the old records are still there, senders still have them on their list.[3] So some mail may still go to the old provider. And like any record, old copies can sit in caches for a while. The chapter on TTL explains how long.

What MX records don't do

MX records only say where to deliver mail. Other DNS records help a receiving server check that mail really came from your domain. That topic is outside this guide.

Some of those checks are stored in TXT records.[6] The next chapter explains what TXT records are.

Sources

  1. RFC 1035: Domain names - implementation and specification, IETF (accessed 2026-10-18)
  2. MX record, Wikipedia (accessed 2026-10-18)
  3. RFC 5321: Simple Mail Transfer Protocol, IETF (accessed 2026-10-18)
  4. RFC 2181: Clarifications to the DNS Specification, IETF (accessed 2026-10-18)
  5. RFC 7505: A "Null MX" No Service Resource Record for Domains That Accept No Mail, IETF (accessed 2026-10-18)
  6. TXT record, Wikipedia (accessed 2026-10-18)