An MX record (Mail Exchanger) is a DNS resource record that specifies the mail servers responsible for receiving email messages for a domain. Within the Simple Mail Transfer Protocol (SMTP), it maps a domain name to a list of authorized message transfer agents (MTAs). Unlike A or AAAA records, an MX record must point to a fully qualified domain name (FQDN) rather than a raw IP address.
How it works
Each MX record contains two core values: a preference (priority) integer and a target mail server hostname. A lower preference number indicates higher priority, meaning sending servers attempt delivery to the lowest-numbered host first. If that primary MTA is unreachable or times out, the sending server automatically falls back to the host with the next lowest preference value. Assigning equal preference values to multiple hosts distributes incoming traffic across them for basic load balancing.
When a server sends an email to [email protected], the delivery process follows a predictable lookup chain:
- The sending MTA queries DNS for the MX records attached to
example.com. - DNS returns the prioritized list of target hostnames.
- The sending server performs a secondary A (IPv4) or AAAA (IPv6) lookup on the highest-priority hostname to resolve its IP address.
- The sender initiates an SMTP session with that IP address—typically over TCP port 25—and transfers the message.
Example
In a standard BIND zone file, configuring a primary mail server alongside a backup relay looks like this:
example.com. 3600 IN MX 10 mail1.example.com.
example.com. 3600 IN MX 20 mail2.example.com.
mail1 3600 IN A 198.51.100.10
mail2 3600 IN A 198.51.100.20
You can verify live MX propagation from a terminal using dig:
dig +short MX example.com
What matters when choosing a server or hosting
- Clean IP reputation: Self-hosting an MTA requires dedicated IP addresses with valid reverse DNS (PTR) records. Shared hosting IPs often suffer from blocklisting caused by neighboring tenants.
- Port 25 availability: Many cloud providers block outbound and sometimes inbound TCP port 25 by default to curb spam, requiring a support request or a dedicated mail relay.
- DNS provider reliability: Because every incoming email depends on MX resolution, your authoritative DNS host needs low latency, anycast routing, and fast TTL propagation during migrations.
- Spam filtering and failover: Managed email hosts and security gateways provide built-in greylisting and quarantine queues, reducing the operational overhead of maintaining secondary backup MX servers.
Common mistakes
- Pointing an MX record to an IP address: Entering an IPv4 or IPv6 address instead of a hostname violates RFC standards and causes compliant sending servers to reject delivery.
- Pointing an MX record to a CNAME: An MX target must resolve directly to an A or AAAA record. Chaining an MX record to a CNAME introduces extra lookups and breaks delivery on strict MTAs.
- Leaving old MX records active during migrations: Failing to delete legacy provider records alongside new ones splits incoming mail unpredictably between old and new inboxes.
- Forgetting trailing dots in zone files: Omitting the trailing period on an FQDN (writing
mail.example.cominstead ofmail.example.com.) causes BIND-style parsers to append the origin domain twice.
FAQ
Can a domain work without an MX record?
Yes, under SMTP fallback rules, if a domain has no MX record, sending servers attempt to deliver mail directly to the domain's A or AAAA record. However, relying on this behavior is unreliable and often flagged as misconfigured by modern spam filters.
What is a Null MX record?
A Null MX record (0 .) explicitly signals that a domain does not accept incoming email. Publishing it prevents sending servers from retrying delivery and protects non-mail domains from unnecessary SMTP connection attempts.
Does changing MX records affect outgoing email?
No. MX records only govern where incoming email is routed. Outgoing email delivery relies on your application's SMTP submission settings along with SPF, DKIM, and DMARC records.