MX record: what it is and how to check it

Tells other mail servers where to deliver email for your domain, in order of preference.

Check with the MX Lookup

What it is

An MX record (mail exchange) tells the rest of the internet which servers accept email for your domain. When someone sends a message to anna@example.com, their mail server looks up the MX records of example.com and delivers the message to one of the servers listed.

MX records are defined in RFC 1035, and the way senders use them is described in RFC 5321, the SMTP specification.

How it works

Each MX record has two parts: a preference number and a mail server name. When a sending server has a message for your domain:

  1. It looks up the MX records of the domain after the @.
  2. It sorts them by preference, lowest first.
  3. It looks up the A and AAAA records of the first server name and connects to it on port 25.
  4. If that server cannot be reached, it tries the next one. Servers with equal preference are tried in random order, which spreads the load.
  5. If none answers, the sender queues the message and retries for several days before giving up.

If a domain has no MX record at all, RFC 5321 tells senders to treat the domain’s own A or AAAA record as an implicit MX. That is why domains that never receive mail should say so explicitly with a null MX (RFC 7505): a single MX with preference 0 and target .. Senders then reject the message immediately instead of trying for days.

MX and secure delivery

Classic SMTP encrypts mail in transit only opportunistically: if a connection cannot be encrypted, or an attacker strips the encryption, many senders deliver in plain text anyway. Two newer standards, both published in DNS, let you ask for better:

  • MTA-STS (RFC 8461) publishes a policy listing your MX host names and requiring senders to use TLS with a valid certificate for them.
  • TLS-RPT (RFC 8460) tells senders where to report problems they meet when connecting to your MX servers.

Both refer to the MX names, so update them whenever your MX records change.

Syntax and fields

Field Example Meaning
Name example.com. The domain that receives mail, the part after @.
TTL 3600 Cache lifetime in seconds.
Class IN Internet.
Type MX The record type.
Preference 10 0 to 65535. Lower values are tried first.
Exchange mx1.example.com. Host name of the mail server. Must have A or AAAA records.

The preference numbers only matter relative to each other: 10 and 20 behave exactly like 1 and 2. Leaving gaps makes it easier to add servers later.

Examples

A primary and a backup mail server:

example.com.        3600  IN  MX    10 mx1.example.com.
example.com.        3600  IN  MX    20 mx2.example.com.
mx1.example.com.    3600  IN  A     192.0.2.25
mx2.example.com.    3600  IN  A     198.51.100.25

Two servers with equal preference, sharing the load:

example.com.        3600  IN  MX    10 mx-a.mail.example.net.
example.com.        3600  IN  MX    10 mx-b.mail.example.net.

A null MX for a domain that never receives email, typically combined with an SPF record that authorises no senders:

example.org.        3600  IN  MX    0 .
example.org.        3600  IN  TXT   "v=spf1 -all"

Common mistakes

  • Pointing MX to an IP address. MX 10 192.0.2.25 is invalid. Create a host name such as mail.example.com with an A record and point the MX to it.
  • Pointing MX to a CNAME. RFC 2181 forbids it. Some senders cope, others do not, so the problem appears as “some people cannot email us”.
  • Leaving old records after a migration. If the old provider’s MX stays with a low preference, some mail keeps going there. When you switch providers, remove every old MX.
  • A backup MX that is not maintained. A secondary server with outdated spam filtering, or one that accepts mail it cannot deliver, is a common source of spam and lost messages. If you do not run a properly configured backup, one MX (or several from the same provider) is better than a neglected one.
  • Forgetting the trailing dot. In zone files, mx1.example.com without the dot becomes mx1.example.com.example.com..
  • No address record for the target. The target must resolve. An MX pointing to a name with no A or AAAA record is a dead end.
  • Confusing receiving with sending. MX records do not make your outgoing mail trusted. For that you need SPF and DKIM in TXT records, plus DMARC.

How to check it

The MX lookup lists each mail server with its preference and TTL, sorted the way senders will try them. For a complete picture of your domain’s email setup, the email checker also verifies that the MX targets resolve, detects a null MX, and checks SPF, DMARC, DKIM, MTA-STS, TLS-RPT and BIMI with a score.

If you have just changed providers, run the DNS propagation checker with type MX to compare the authoritative answer with what public resolvers have in cache.

  • TXT: holds SPF, DMARC, DKIM, MTA-STS and TLS-RPT policies for email.
  • A and AAAA: every MX target needs them.
  • PTR: reverse DNS for the IP addresses that send your mail.
  • CNAME: must not be used as an MX target.

Frequently asked questions

Does a lower or higher MX number win?

Lower wins. A sending server tries the MX with the lowest preference value first and moves to higher values only if the lower ones cannot be reached. Records with the same value are tried in random order.

What happens if a domain has no MX record?

Under RFC 5321, if there is no MX record the sender falls back to the domain's A or AAAA record and tries to deliver there (the 'implicit MX'). If the domain should never receive mail, publish a null MX instead (RFC 7505).

Can an MX record point to an IP address?

No. The MX target must be a host name that has A or AAAA records. It must not be an IP address and should not be a CNAME.

Does the MX record control where my email is sent from?

No. MX only controls incoming mail. Which servers may send mail for your domain is declared with SPF, and messages are signed with DKIM. Use the email checker to test all of them together.

How long does it take to change mail providers?

New MX records reach senders within the old record's TTL, typically one hour. During that window some mail may still arrive at the old provider, so keep the old mailbox active for a day or two after the switch.