HTTPfy

MX record

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.

Live MX records from real domains

Checked at via public DNS
gmail.comMX
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.comMX
github.com. 300 IN MX 0 github-com.mail.protection.outlook.com.
  ; preference 0: deliver to github-com.mail.protection.outlook.com
microsoft.comMX
microsoft.com. 3600 IN MX 10 microsoft-com.mail.protection.outlook.com.
  ; preference 10: deliver to microsoft-com.mail.protection.outlook.com
proton.meMX
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

What the MX record does

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.

Zone-file syntax

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.

Fields

FieldMeaning
Preference0 to 65535. Lower is tried first. Only the relative order matters: 10/20 behaves the same as 1/2.
ExchangeHostname of the mail server. It must have A or AAAA records and must not be a CNAME or an IP address.

Common mistakes

  • Putting an IP address in the exchange field. MX targets must be hostnames.
  • Pointing MX at a CNAME. Many senders cope, but RFC 2181 forbids it and some refuse.
  • Keeping a backup MX that has no spam filtering or does not know the valid recipients. Spammers deliver to it on purpose.
  • Forgetting to update SPF and MTA-STS policies after changing mail provider.

Specification

  • RFC 1035: Domain names - implementation and specification
  • RFC 5321: Simple Mail Transfer Protocol (section 5.1)
  • RFC 7505: A "Null MX" No Service Resource Record

Related record types

  • SPF: which servers may send mail for a domain
  • DMARC: policy and reporting for the From domain
  • MTA-STS: enforce TLS for incoming mail
  • TLSA: DANE certificate pinning in DNS

All DNS record types