MX RecordMail Exchanger Record
An MX record (Mail Exchanger record) is the DNS entry that tells other servers which mail servers accept email for your domain, and in what order to try them. Each record pairs a preference number with a server hostname, and the lowest number wins. Defined in RFC 5321, it is the record a sending server looks up first, before any SMTP connection is made.
- Points a domain to the mail servers that accept its incoming email
- Lower preference numbers are tried first; they are higher priority
-
It must point to a hostname with an
AorAAAArecord, never aCNAME - Multiple records give you failover across backup mail servers
MX (Mail Exchanger)
preference hostname
A/AAAA record
CNAME
How MX records route mail
When a server has mail for you@example.com, the first thing it does is look up the MX records for example.com. The answer is one or more lines, each with a preference value and a mail-server hostname. The sending server sorts them by preference, lowest first, and opens an SMTP connection to that host. If it cannot connect, it falls through to the next-lowest preference, which is exactly how backup mail servers work.
The preference number trips people up because it runs backwards from intuition: a record with preference 10 is tried before one with preference 20. Lower means higher priority. If two records share the same preference, the sender picks between them at random, spreading load across equal servers.
example.com. 3600 IN MX 10 mail.example.com.
example.com. 3600 IN MX 20 backup.example.com.
The rule that breaks mail: no CNAME, no IP
An MX record must point to a hostname that has its own A or AAAA record. Two things it must not point to:
- An IP address.
MX 10 203.0.113.10is invalid. The target is always a name, never a raw IP. - A
CNAMEalias. RFC 5321 requires the MX target to resolve directly to address records, and the DNS specs forbid aiming it at a CNAME. Strict receivers will reject mail when you do.
This is one of the most common quiet misconfigurations: the domain looks fine, mail mostly flows, then one strict receiver bounces everything because the MX points at a CNAME. Always target a real hostname with an A or AAAA record, and confirm it with an MX lookup.
MX records and deliverability
MX records govern inbound mail, the messages other people send to you, so they are not part of your outbound authentication. But they matter for reputation in two ways. First, a domain with no MX record (or one pointing at a dead host) cannot receive replies, bounces, or the verification mail that many sign-up and feedback systems send, which makes the domain look abandoned. Second, some receivers and anti-spam systems treat a sending domain that has no working MX as a weak signal, since a legitimate domain almost always accepts mail back.
The practical takeaway: keep your MX records pointed at live, correctly configured servers, list a backup if you can, and verify them whenever you change mail providers. A broken MX is invisible until someone tries to reply to you.
How a server uses your MX records
you@example.comMX records for example.comA/AAAA record to an IPValid vs invalid MX targets
| Valid | Invalid | |
|---|---|---|
| Target | A hostname with an A/AAAA record | A raw IP address or a CNAME |
| Example | 10 mail.example.com. |
10 203.0.113.10 |
| Spec | Meets RFC 5321 | Breaks RFC 5321 / RFC 2181 |
| Result | Mail is accepted | Strict receivers reject mail |
By the numbers
Common mistakes
10 is the primary; 20 is the backup. Setting your main server to a high number quietly demotes it.Frequently asked questions
MX 10 is your primary server and MX 20 is a backup.