A Mail Exchanger (MX) Record is a type of Resource Record in the Domain Name System (DNS) that specifies the mail server responsible for accepting email messages on behalf of a domain name.
Without valid MX records, sending servers cannot locate your mail infrastructure, causing incoming emails to bounce or fail delivery.
When someone sends an email to user@example.com, the sender's mail transfer agent (MTA) performs the following steps:
# **DNS Lookup:** Queries DNS for the ''MX'' records associated with ''example.com''.
# **Priority Resolution:** Sorts the returned MX hostnames by their preference (priority) number.
# **A/AAAA Lookup:** Resolves the primary MX hostname to an IP address (''A'' or ''AAAA'' record).
# **SMTP Connection:** Attempts an SMTP connection to the primary mail server on port ''25''. If the primary server is unreachable, it attempts to connect to secondary backup servers in order of priority.
An MX record consists of three core components:
| Component | Value Example | Description |
|---|---|---|
| Name / Host | @ or example.com | The domain name receiving the email. |
| Preference / Priority | 10 | Integer value indicating server priority (lower numbers = higher priority). |
| Mail Server / Target | mail.example.com | The Fully Qualified Domain Name (FQDN) of the mail server. |
Crucial Rule: The target of an MX record MUST point to a valid domain name (AorAAAArecord). It must never point directly to an IP address or aCNAMEalias.
Priorities allow domain administrators to set up primary and backup fallback mail servers.
Priority 10 : mail1.example.com <-- Primary Mail Server (Tried First) Priority 20 : mail2.example.com <-- Secondary / Backup Server (Tried if Priority 10 fails)
10), incoming mail load is distributed between them (round-robin / load balancing).5 takes precedence over Priority 10.| Record Type | Host | Priority | Value / Target | TTL |
|---|---|---|---|---|
| MX | @ | 10 | mail.example.com. | 3600 |
| A | mail | — | 192.0.2.25 | 3600 |
| Record Type | Host | Priority | Value / Target | TTL |
|---|---|---|---|---|
| MX | @ | 1 | SMTP.GOOGLE.COM. | 3600 |
Pointing an MX record to a target that is a CNAME alias violates RFC 2181 (Section 10.3) and can lead to unpredictable mail loop errors or bounced emails.
MX records require an FQDN as their target. Pointing directly to an IPv4/IPv6 address will cause syntax validation failures across major mail servers.
In raw DNS zone files, failing to append a trailing dot (mail.example.com.) may cause DNS servers to append the root domain twice (mail.example.com.example.com).
You can test and verify your MX records using Telenegar Tools or terminal commands:
bash dig +short example.com MX
cmd nslookup -type=MX example.com