An MX (mail exchanger) record names a host that accepts email for the domain, with a preference number that sets the order senders try them in.
gmail.com. 2087 IN MX 5 gmail-smtp-in.l.google.com. ; preference 5: deliver to gmail-smtp-in.l.google.com gmail.com. 2087 IN MX 10 alt1.gmail-smtp-in.l.google.com. ; preference 10: deliver to alt1.gmail-smtp-in.l.google.com gmail.com. 2087 IN MX 20 alt2.gmail-smtp-in.l.google.com. ; preference 20: deliver to alt2.gmail-smtp-in.l.google.com gmail.com. 2087 IN MX 30 alt3.gmail-smtp-in.l.google.com. ; preference 30: deliver to alt3.gmail-smtp-in.l.google.com gmail.com. 2087 IN MX 40 alt4.gmail-smtp-in.l.google.com. ; preference 40: deliver to alt4.gmail-smtp-in.l.google.com
github.com. 300 IN MX 0 github-com.mail.protection.outlook.com.
; preference 0: deliver to github-com.mail.protection.outlook.com
microsoft.com. 3600 IN MX 10 microsoft-com.mail.protection.outlook.com.
; preference 10: deliver to microsoft-com.mail.protection.outlook.com
proton.me. 1155 IN MX 10 mail.protonmail.ch. ; preference 10: deliver to mail.protonmail.ch proton.me. 1155 IN MX 20 mailsec.protonmail.ch. ; preference 20: deliver to mailsec.protonmail.ch
A sending server looks up the MX records of the recipient's domain, sorts them by preference (lowest first) and tries each host in turn. Hosts with equal preference are tried in random order, which spreads load. If a domain has no MX records at all, RFC 5321 says the sender falls back to the domain's own A/AAAA record (the "implicit MX").
To state that a domain accepts no mail, publish the null MX from RFC 7505: a single record 0 .. Senders then bounce immediately instead of retrying for days.
example.com. 3600 IN MX 10 mx1.example.com.
example.com. 3600 IN MX 20 mx2.example.com.
Wire format: RDATA is a 16-bit PREFERENCE followed by the EXCHANGE domain name.
| Field | Meaning |
|---|---|
| Preference | 0 to 65535. Lower is tried first. Only the relative order matters: 10/20 behaves the same as 1/2. |
| Exchange | Hostname of the mail server. It must have A or AAAA records and must not be a CNAME or an IP address. |