A DNS MX record (Mail Exchange record) specifies the mail servers responsible for accepting incoming email on behalf of a domain. Without correctly configured MX records, nobody can send email to addresses at your domain. Every domain that uses email must have at least one MX record published in its DNS zone.
What Is an MX Record?
When someone sends an email to hello@example.com, the sending mail server (SMTP server) does not deliver directly to the recipient's inbox. Instead, it queries DNS for the MX records of example.com. The DNS response returns one or more mail server hostnames with associated priority values. The sending server then connects to the highest-priority mail server listed and delivers the message.
Importantly, an MX record always points to a hostname — never directly to an IP address. The hostname must itself have an A or AAAA record. The MX record cannot point to a CNAME record; this is explicitly prohibited in RFC 2181.
MX Record Syntax
MX records include an additional field not found in A or CNAME records: the priority(also called preference) value. This is an integer between 0 and 65535 — lower numbers indicate higher priority.
; MX record syntax
; NAME TTL CLASS TYPE PRIORITY MAIL SERVER (hostname)
example.com. 3600 IN MX 10 mail.example.com.
example.com. 3600 IN MX 20 backup-mail.example.com.
; The mail.example.com host must have its own A record:
mail.example.com. 3600 IN A 203.0.113.25Understanding MX Priority Values
The priority value controls which mail server the sending SMTP server tries first:
- A lower number means higher priority. The sending server always tries the lowest-numbered MX record first.
- If the preferred server is unavailable, the sender falls back to the next-lowest priority server.
- If two MX records share the same priority, the sending server may choose between them at random — providing simple load balancing.
Multiple MX Records for Redundancy
Publishing multiple MX records is standard practice. If your primary mail server is unavailable, sending servers will queue the message and retry, eventually trying lower-priority (higher number) fallback servers. This ensures email is not permanently lost during brief outages.
; Multiple MX records with different priorities
; Primary mail server (highest priority — lowest number)
example.com. 3600 IN MX 10 aspmx.l.google.com.
; Secondary servers (lower priority — higher numbers)
example.com. 3600 IN MX 20 alt1.aspmx.l.google.com.
example.com. 3600 IN MX 30 alt2.aspmx.l.google.com.
example.com. 3600 IN MX 40 alt3.aspmx.l.google.com.
example.com. 3600 IN MX 50 alt4.aspmx.l.google.com.MX Records for Common Email Providers
Major email hosting providers publish specific MX records that you configure in your DNS zone. Here are the standard MX record sets for the two most popular providers:
Google Workspace (Gmail)
; Google Workspace MX records
example.com. 3600 IN MX 1 aspmx.l.google.com.
example.com. 3600 IN MX 5 alt1.aspmx.l.google.com.
example.com. 3600 IN MX 5 alt2.aspmx.l.google.com.
example.com. 3600 IN MX 10 alt3.aspmx.l.google.com.
example.com. 3600 IN MX 10 alt4.aspmx.l.google.com.Microsoft 365 (Exchange Online)
; Microsoft 365 MX record (tenant-specific hostname)
; Replace "contoso-com" with your tenant's mail hostname
example.com. 3600 IN MX 0 contoso-com.mail.protection.outlook.com.How the MX Lookup Process Works
When a mail server needs to deliver a message to user@example.com, it follows these steps:
- The sending MTA (Mail Transfer Agent) extracts the domain portion:
example.com. - It queries DNS for MX records at
example.com. - DNS returns a list of MX records, each with a priority value and a mail server hostname.
- The MTA sorts the records by priority (lowest number first).
- It opens an SMTP connection to the highest-priority server on port 25.
- If that server is unavailable, the MTA retries with the next-priority server.
- If all servers are unavailable, the MTA queues the message and retries over the next several hours.
How to Look Up MX Records
Use the ShowDNS MX Lookup tool to instantly check the MX records for any domain. The tool queries authoritative nameservers and displays all MX records in priority order, along with each mail server's TTL and resolved IP address.
On the command line, use dig:
; Query MX records with dig
dig example.com MX
;; ANSWER SECTION:
example.com. 3600 IN MX 10 aspmx.l.google.com.
example.com. 3600 IN MX 20 alt1.aspmx.l.google.com.Frequently Asked Questions
Can an MX record point to a CNAME?
No. RFC 2181 explicitly prohibits MX records from pointing to names that are themselves CNAME records. An MX record must point to a hostname that has its own A or AAAA record. Many mail servers and DNS validators will reject or ignore MX records pointing to CNAMEs, which can cause silent email delivery failures.
What does priority 0 mean in an MX record?
Priority 0 is the highest possible priority — it means the mail server should always be tried first. Microsoft 365 uses priority 0 for its single MX record because it manages redundancy internally. There is nothing technically special about 0 compared to other values; it simply represents the lowest number in the set, ensuring that server is always preferred.
What happens if I have no MX record?
If a domain has no MX record, the DNS specification (RFC 5321) says the sending server should fall back to the domain's A record and attempt delivery there. In practice, most modern mail servers do not follow this fallback and will return a bounce indicating the domain has no mail exchanger. Always configure an explicit MX record for any domain that should receive email.
How long does it take for MX record changes to take effect?
MX record changes propagate based on their TTL. With a common TTL of 3600 seconds (one hour), senders may continue delivering to old mail servers for up to one hour. Before switching email providers, lower your MX TTL to 300 seconds and wait for the current TTL to expire. This ensures that once you update the MX records, all senders pick up the change within five minutes.
Should I delete old MX records when switching email providers?
Yes — always remove the old provider's MX records when you switch. Leaving them in place can cause incoming email to split between the old and new mail servers, resulting in messages being delivered to your old provider's infrastructure where you can no longer access them. Switch MX records atomically: remove the old records and add the new ones at the same time.