What Is an MX Record and How to Check It
An MX (Mail Exchange) record is a type of DNS resource record that specifies the mail server responsible for accepting email messages on behalf of a domain name. Without a properly configured MX record, your domain cannot receive incoming emails from external senders like Gmail or Outlook.
Understanding how these records work and knowing how to inspect them is essential for maintaining reliable business communication and fixing delivery failures.
Understanding the Anatomy of an MX Record
When someone sends an email to user@example.com, their mail transfer agent (MTA) queries the Domain Name System for the MX records of example.com. The returned data tells the sending server exactly where to deliver the message.
An MX record consists of two primary components:
- Priority (Preference): A number indicating the order in which mail servers should be contacted. Lower numbers mean higher priority.
- Target Hostname: The fully qualified domain name (FQDN) of the mail server handling the traffic.
Why Priority Matters
Priority values allow administrators to set up redundancy and load balancing for email delivery. Typically, an organization configures a primary mail server with a low priority number (such as 10) and one or more backup servers with higher priority numbers (such as 20 or 30).
If the primary mail server goes offline for maintenance or experiences an outage, the sending server automatically attempts to deliver the message to the backup server with the next lowest priority value.
Standard MX Record Syntax
When configuring your domain’s DNS zone file through your registrar or hosting provider, the syntax for an MX record generally looks like this:
example.com. IN MX 10 mail.example.com.
example.com. IN MX 20 mail-backup.example.com.
In this example, mail.example.com is the preferred destination, while mail-backup.example.com serves as the failover target. Note that the target hostname must resolve to an A or AAAA record; it should never point directly to an IP address.
How to Perform an MX Lookup
Checking your domain's MX records is the first step when troubleshooting email delivery issues, such as messages bouncing or failing to arrive. You can use command-line utilities or web-based interfaces to query public DNS servers.
Using Command-Line Tools
If you prefer using the terminal, both Linux and macOS offer built-in utilities like dig and nslookup.
To check MX records using dig, open your terminal and run:
dig example.com MX
The output will display an "ANSWER SECTION" showing the priority and target mail servers associated with the domain.
To perform the same check using nslookup, run:
nslookup -type=MX example.com
On Windows, nslookup requires you to switch to query type mode first:
nslookup
set type=MX
example.com
Using Web-Based Tools
Command-line tools are powerful, but web utilities offer instant insights without requiring terminal access. You can easily diagnose mail routing configurations by using the MX Lookup tool to query global name servers and verify that your mail servers are reachable.
Common MX Record Misconfigurations
Even experienced administrators occasionally make mistakes when setting up DNS zones. Watch out for these frequent issues:
- Pointing to an IP Address: An MX record must always point to a domain name (a hostname), never a raw IPv4 or IPv6 address.
- Missing A/AAAA Records: If your MX record points to
mail.example.com, but that subdomain lacks a valid A record, sending servers will fail to resolve the destination. - Incorrect Priority Assignment: Setting all mail servers to the same priority can cause erratic load distribution, while using invalid numbers can break RFC compliance.
- Conflicting CNAME Records: Never create a CNAME record for a domain apex (like
example.com) that also has MX records, as this violates DNS standards.
MX Record Configuration Checklist
Before you finish setting up your email routing, run through this quick checklist to ensure everything is correct:
- Verified that the MX record domain matches the intended recipient domain.
- Confirmed that priority numbers are set logically (e.g., 10 for primary, 20 for backup).
- Ensured the target hostnames point to valid mail servers.
- Checked that corresponding A or AAAA records exist for the mail server hostnames.
- Performed a live lookup to verify global DNS propagation.