MX Record

Mail Exchange

Type code
15
Status
In use
Defined in
RFC 1035

What the MX record is for

When a mail server delivers a message to user@example.com, it looks up the MX records for example.com and connects to the listed hosts, lowest PREFERENCE value first. Hosts with the same preference are tried in random order.

If a domain has no MX records, RFC 5321 says senders fall back to the domain's own A or AAAA record (the implicit MX). A domain that receives no mail can say so explicitly with a null MX: a single record with preference 0 and exchange "." (RFC 7505).

The EXCHANGE must be a host name with its own A or AAAA records, not an alias or an IP address.

Wire format and fields

FieldSizeMeaning
PREFERENCE16 bitsThe priority of this host. Lower values are preferred.
EXCHANGEdomain nameThe host name of a mail server for the owner name.

Zone file syntax

<owner> <ttl> IN MX <preference> <exchange>

Example

The MX records at gmail.com, fetched from live DNS on 27 November 2026:

gmail.com. 120 IN MX 40 alt4.gmail-smtp-in.l.google.com.
gmail.com. 120 IN MX 10 alt1.gmail-smtp-in.l.google.com.
gmail.com. 120 IN MX 20 alt2.gmail-smtp-in.l.google.com.
gmail.com. 120 IN MX 30 alt3.gmail-smtp-in.l.google.com.
gmail.com. 120 IN MX 5 gmail-smtp-in.l.google.com.

Common mistakes

  • Pointing an MX record at a CNAME. RFC 2181 and RFC 5321 forbid it, and some senders will not deliver.
  • Putting an IP address in the EXCHANGE field. It must be a host name that has A or AAAA records.
  • Reading the preference backwards: the lowest number is tried first, not the highest.
  • Publishing no MX on a domain that sends but never receives mail. Senders then try its A record; a null MX ("0 .") tells them not to.
  • Running a backup MX that does not apply the same spam and recipient checks as the primary, so it becomes the easier way in.

Specifications

  • RFC 1035: Domain names - implementation and specification
  • RFC 5321: Simple Mail Transfer Protocol (Section 5 defines how senders use MX records, including the fallback to A/AAAA.)
  • RFC 7505: A "Null MX" No Service Resource Record for Domains That Accept No Mail (Defines the null MX ("0 .") for domains that receive no mail.)
  • RFC 2181: Clarifications to the DNS Specification (Says the EXCHANGE must not be an alias (CNAME).)
  • IANA DNS Resource Record (RR) TYPEs registry: type code and status

Related record types

Domain Intelligence APIs

Get started with our easy-to-use API docs.