A Mail Exchanger (MX) record is a DNS entry that tells the internet which mail server handles incoming email for your domain. If you want to receive emails at your domain, you must have at least one MX record configured. Without these records, sending servers will not know where to deliver your messages, causing them to bounce or fail.
What is an MX Record?
An MX record is a resource record in the Domain Name System (DNS) that acts as a traffic director for the Simple Mail Transfer Protocol (SMTP). It specifies the destination mail server using a hostname rather than an IP address.
When someone sends an email to you, their mail transfer agent (MTA) queries your domain’s DNS to find these records. The MTA then attempts to establish an SMTP connection with the servers listed in your MX records to hand off the message.
Why MX Records matter
- Email Delivery: They are the only way to ensure inbound email reaches your intended inbox provider.
- Redundancy: You can list multiple servers so that if your primary mail host goes down, a backup server can accept the mail.
- Load Balancing: Settings can be adjusted to distribute incoming email traffic across several servers to prevent any single server from becoming overwhelmed.
- Security Filtering: MX records allow you to route mail through third-party spam filters or security gateways before it reaches your final destination.
How an MX Record works
The delivery process follows a specific sequence of logic controlled by the DNS and the sending mail agent.
- The DNS Query: When an email is sent, the sending server checks the DNS of the recipient domain for MX entries.
- Priority Sorting: The DNS returns a list of mail servers along with their priority values.
- Connection Attempt: The sending server tries to connect to the server with the lowest priority number first.
- Failover: If the top-priority server is unavailable, the sender tries the next server in the list based on the numerical order.
- Fallback: If no MX records are found at all, the [sending agent will attempt to deliver the mail to the domain's A record] (Wikipedia) as a last resort.
MX Record components
Every MX record contains specific fields that define how the mail server should be treated by the rest of the internet.
| Field | Purpose | Example |
|---|---|---|
| Host/Domain | The domain name the record applies to (often represented by the @ symbol). | example.com |
| Record Type | Identifies this specifically as an MX entry. | MX |
| Priority | A number indicating which server to use first (lower numbers are higher priority). | 10 |
| Value/Destination | The hostname of the mail server (must be an A or AAAA record). | mail.example.com |
| TTL | Time to Live; how long the record is stored in cache before checking for updates. | 3600 |
Best practices
Set multiple MX records. Configure at least two different mail servers to ensure your domain can still receive mail if your primary provider experiences an outage.
Use 10-unit intervals for priority. Assign priorities like 10, 20, and 30. This leaves space to insert new servers in between later without renumbering your entire list.
Point to A records only. Ensure your MX record points directly to a mail server's hostname that has its own A or AAAA record. [Pointing an MX record to a CNAME alias is forbidden] (Cloudflare) by official internet standards.
Keep TTL reasonable. Set a lower TTL (e.g., 300 seconds) when you plan to migrate mail providers so changes propagate across the internet faster. Increase it once the migration is stable to reduce DNS server load.
Common mistakes
Mistake: Using an IP address in the "Value" field. Fix: MX records must point to a hostname (like mail.google.com), not a direct IP (like 192.0.2.1). The hostname must then have its own A record to resolve to an IP.
Mistake: Pointing to a CNAME. Fix: Always point your MX record to the "canonical" name (the A record) of the server to avoid delivery delays or failures.
Mistake: Identifying a backup server with equal priority to the primary. Fix: Only use equal priority numbers if you intend to [equally balance the load between servers] (Cloudflare). If one server is a backup, it must have a higher numerical priority value.
Mistake: Assuming the priority number has a specific "value." Fix: The priority is relative. A server with priority 100 is preferred over a server with priority 200. The [range for this field is 0 to 65535] (Wikipedia).
MX Record vs A Record
| Feature | MX Record | A Record |
|---|---|---|
| Primary Goal | Routes email traffic specifically. | Maps a domain to an IP address. |
| Target Requirement | Must point to a hostname. | Must point to an IPv4 address. |
| Priority System | Uses a numerical priority field. | No priority field (uses order of entry). |
| Failover | Built-in logic for multiple servers. | Requires manual or advanced DNS setups. |
Rule of thumb: Use MX records to tell the world where your mail goes; use A records to tell the world where your website or server lives.
FAQ
What happens if I have no MX record?
If no MX record exists, many mail systems will try to deliver mail to the IP address listed in your domain's A record. However, this is unreliable and not supported by all mail services. You should always have a dedicated MX record to ensure consistent delivery.
What is a "Null MX" record?
A Null MX record is a specific configuration used for domains that are not intended to receive any email. It signals to sending servers that they should not even attempt delivery, which helps reduce unnecessary traffic and bounce processing.
How do I check if my MX records are working?
You can use lookup tools to query your domain's authoritative name servers. Diagnostic tools can connect to the mail server, verify reverse DNS records, and [check each IP address against over 100 blacklists] (MXToolbox) to ensure your mail is not being blocked.
Does a lower priority number mean it is more important?
Yes. In DNS logic, "lowest is best." A server with a priority of 0 or 5 will always be tried before a server with a priority of 10 or 20.
Can I have two servers with the same priority?
Yes. If two servers share the same priority level, the [sender will randomize the load between them] (Wikipedia) to distribute the incoming email traffic evenly.