MX record at a glance

FieldValue
Type code15
Defined inRFC 1035; mail use in RFC 5321, section 5
ValueA preference number and a hostname, such as 10 mx1.example.com.
Allowed at the apexYes, and that is where it usually lives
Target rulesA hostname with its own A or AAAA records; never an IP address or a CNAME

Here is how an MX record looks in a zone file:

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

Each MX target needs its own address records, shown here as the A records for mx1 and mx2.

How senders use MX records

To deliver to [email protected], a sending server looks up the MX records for example.com, sorts them by preference (lowest number first), resolves each target to an address, and tries them in order. Hosts with equal preference are tried in random order, which spreads load. If every host fails, the sender queues the message and retries for days before bouncing it.

If a domain has no MX records at all, RFC 5321 tells senders to fall back to the domain's own A or AAAA records (the "implicit MX"). That fallback is why a domain that never sends or receives mail should say so explicitly.

Null MX: saying "no mail here"

A null MX (RFC 7505) is a single MX record with preference 0 and a target of a lone dot: example.com. IN MX 0 .. It tells senders immediately that the domain accepts no mail, so they bounce instead of retrying. Pair it with an SPF record of v=spf1 -all and a DMARC reject policy for parked or web-only domains.

MX and email security

MX only routes mail. Authentication and transport security live in other records, most of them TXT: SPF at the apex, DKIM under _domainkey, DMARC at _dmarc, and MTA-STS and TLS-RPT for encrypted delivery. A domain can have perfect MX records and still fail DMARC. Email phishing protection with SPF, DKIM and DMARC and why email is not delivered cover the rest of the picture.

How to look up an MX record

Each tool below sends the query to your default resolver unless you name a server. Swap in your own domain for example.com, and add a public resolver such as 1.1.1.1 to compare answers with what your network sees.

dig (macOS, Linux, WSL)

CommandWhat it does
dig example.com MXThe full answer, with preference values and TTL
dig +short example.com MXPreference and target only, one per line
dig +short mx1.example.com AConfirm an MX target resolves to an address
dig +short mx1.example.com CNAMECheck that a target is not a CNAME (no output is good)

nslookup (Windows, macOS, Linux)

CommandWhat it does
nslookup -type=MX example.comMail servers and their preferences
nslookup -type=MX example.com 8.8.8.8The same question, asked of Google Public DNS
nslookup mx1.example.comAddresses for one MX target

PowerShell (Windows)

CommandWhat it does
Resolve-DnsName -Name example.com -Type MXMX records, with NameExchange and Preference columns
Resolve-DnsName example.com -Type MX | Where-Object Section -eq 'Answer'Only the answer rows, without extra address records a server may add
Resolve-DnsName example.com -Type MX | Sort-Object PreferenceSorted the way a sender would try them

Common mistakes

  • An MX target that is a CNAME. Forbidden by RFC 2181 and RFC 5321; some senders refuse it.
  • An MX target that is an IP address. MX takes a hostname. Create an A record for the host and point MX at that name.
  • Leftover MX records after a migration. An old provider listed at a lower preference keeps receiving mail it can no longer deliver.
  • No MX and no null MX on a domain that does not use mail. Senders fall back to the A record and attackers find it easier to spoof the domain.
  • Missing reverse DNS on a self-hosted mail server. Receivers check the PTR record of the sending IP; see PTR record.

MX records in Domain Visualizer

Domain Visualizer looks up MX at the apex on every scan, follows each target to its addresses, and shows the preference and mail host in the record detail panel. Security Posture then grades the mail setup as part of its email card.

FAQ

What does the number in an MX record mean?

It is the preference. Senders try the lowest number first and move to higher numbers only if the lower ones fail. Equal numbers share the load.

Can MX records point to another company’s servers?

Yes. Hosted email services such as Microsoft 365 and Google Workspace give you MX targets in their own domains. The target only needs to resolve to a server that accepts mail for your domain.

How long does an MX change take to work?

Senders cache MX records for their TTL. Lower the TTL a day ahead of a migration so the switch takes effect within minutes rather than hours.

Sources and further reading