A Receiver's Guide: How MX Records Interact with A and AAAA Records
Understanding the fundamental differences in mx record vs a record email routing is essential for ensuring your organization never loses an incoming message. When someone hits send on a message to user@example.com, mail servers do not simply guess where to deliver it; they follow a strict, multi-step DNS lookup path that relies on both Mail Exchange (MX) records and Address (A or AAAA) records working in absolute harmony. If either of these record types is misconfigured, your mail flow will immediately fail, resulting in bounced messages, lost revenue, and delivery timeouts.
At XiaTools, we built the MX Lookup tool to help you instantly inspect these exact relationships, check server response times, and validate mail server configurations across the global DNS network. Whether you are migrating to a new email provider, setting up a fresh domain, or troubleshooting sudden mail delivery failures, mastering how these records interact will save you hours of frustration.
The Fundamental Definitions
To understand how email delivery functions under the hood, let us look at the distinct roles that MX and A records play within your domain's Domain Name System (DNS) zone file.
What is an MX Record?
A Mail Exchange (MX) record is a standard resource record in DNS that specifies the mail servers responsible for accepting email messages on behalf of a domain name. Crucially, an MX record must point to a domain name (a hostname like mail.example.com), never directly to an IP address. Each MX record contains two core components:
- Priority (Preference): An integer ranging from 0 to 65535, where lower numbers indicate higher preference. Sending mail servers always attempt delivery to the lowest-numbered priority first.
- Target Hostname: The canonical domain name of the mail server capable of handling inbound mail.
What is an A (or AAAA) Record?
An Address record (A record for IPv4, AAAA record for IPv6) translates a human-readable hostname (like mail.example.com or smtp.example.com) into a machine-readable numerical IP address (such as 192.0.2.25 or the IPv6 equivalent 2001:db8::25). Without an A or AAAA record, a hostname is just a string of text; the A record bridges the gap by telling network devices exactly where on the internet that hostname lives.
How MX and A Records Interact During Email Delivery
When a sender's Mail Transfer Agent (MTA)—such as Postfix, Exchange, or Google Workspace—wants to deliver an email to recipient@example.com, it performs a sequential, deterministic series of DNS queries:
- MX Query: The sending MTA asks the DNS root and authoritative nameservers for the MX records associated with
example.com. - Sorting by Priority: The MTA receives a list of MX records, sorts them by priority number, and selects the most preferred (lowest number) server.
- A/AAAA Query: The MTA takes the target hostname found in the selected MX record (for example,
mx1.mailprovider.com) and queries for its corresponding A or AAAA records to retrieve the actual IP address. - Handshake and Delivery: The MTA initiates a TCP connection on port 25 (or port 587/465 depending on submission rules) to that specific IP address to deliver the message via the SMTP protocol.
If the primary mail server's IP address fails to respond, the sending MTA moves to the secondary MX record with the next higher priority number, repeats the A record lookup for that secondary hostname, and tries again.
Comparison Table: MX Records vs A Records
| Feature | MX Record | A Record (IPv4) | AAAA Record (IPv6) |
|---|---|---|---|
| Primary Purpose | Designates mail servers for a domain | Maps a hostname to an IPv4 address | Maps a hostname to an IPv6 address |
| Target Type | Must be a hostname (FQDN), never an IP | Must be a 32-bit numeric IP address | Must be a 128-bit hexadecimal IP address |
| Includes Priority? | Yes (integer preference value) | No | No |
| Direct Email Role | Directs where mail should go | Provides the physical network route | Provides the modern IPv6 network route |
Exact DNS Record Syntax Examples
When configuring your DNS zone file via your domain registrar or cloud DNS provider (such as Cloudflare, AWS Route 53, or cPanel), syntax accuracy is non-negotiable. Here is an example zone file configuration using our documentation network (example.com and 192.0.2.0/24):
; Zone file entries for example.com
@ IN SOA ns1.example.com. admin.example.com. ( 2023100101 7200 3600 1209600 86400 )
; Base domain A records
@ IN A 192.0.2.10
; Mail server hostnames (A and AAAA records)
mail1 IN A 192.0.2.20
mail1 IN AAAA 2001:db8::20
mail2 IN A 192.0.2.30
; MX Records pointing to the hostnames above
@ IN MX 10 mail1.example.com.
@ IN MX 20 mail2.example.com.
Notice that mail1.example.com has both an A record and an AAAA record, giving sending servers the flexibility to connect via IPv4 or IPv6.
Common Mistakes and How to Fix Them
Even experienced network administrators occasionally run into frustrating email delivery failures due to subtle DNS misconfigurations. Review these common pitfalls to keep your mail flowing smoothly:
1. Pointing an MX Record Directly to an IP Address
The Mistake: Entering 192.0.2.20 directly into the value field of an MX record.
Why it Fails: RFC standards explicitly state that an MX record target must be a domain name (FQDN). Many DNS providers will block this outright, and standards-compliant MTAs will reject the record as invalid.
The Fix: Create an A record for your mail server (e.g., mail.example.com IN A 192.0.2.20) and point your MX record to that hostname (@ IN MX 10 mail.example.com).
2. Missing A Records for Custom Mail Hostnames
The Mistake: Setting up an MX record pointing to mail.mycompany.com, but forgetting to create the matching A record for mail.mycompany.com.
Why it Fails: The sending mail server finds the MX record, but when it attempts the subsequent A record lookup to find the IP address, it receives a NXDOMAIN (Non-Existent Domain) error and aborts delivery.
The Fix: Always verify that every hostname referenced in your MX records resolves cleanly to a valid IP address.
3. Using CNAME Records for MX Targets
The Mistake: Pointing an MX record to a target hostname that is actually a CNAME (alias) record. Why it Fails: Per strict DNS specifications (RFC 1912), MX records must never point to a CNAME alias. Doing so breaks mail server lookups across many enterprise mail gateways. The Fix: Always point MX records directly to a standard A or AAAA record hostname, never a CNAME.
Troubleshooting Commands and Output
To verify your email DNS setup from your local terminal, you can use standard command-line diagnostic tools.
Using dig to Check MX and A Records
Run the following command to query the MX records for your domain:
dig example.com MX +noall +answer
Sample output:
example.com. 300 IN MX 10 mail1.example.com.
example.com. 300 IN MX 20 mail2.example.com.
Next, verify that the target hostname resolves correctly to an IP address:
dig mail1.example.com A +noall +answer
Sample output:
mail1.example.com. 300 IN A 192.0.2.20
Using PowerShell on Windows
If you are on Windows, use the Resolve-DnsName cmdlet in PowerShell:
Resolve-DnsName -Name example.com -Type MX
Sample output:
Name Type Priority Target
---- ---- -------- ------
example.com MX 10 mail1.example.com
example.com MX 20 mail2.example.com
Quick DNS Health Checklist for Email
Before launching a new domain or changing email providers, run through this quick checklist:
- Are all MX records pointing to valid hostnames (FQDNs) and never to IP addresses or CNAMEs?
- Do all MX target hostnames have active A (and optionally AAAA) records?
- Are priority numbers correctly set (e.g., 10 for primary, 20 for secondary)?
- Have you verified external resolution using an online lookup tool to bypass local DNS caching?
- Do your reverse DNS (PTR) records match your mail server's outgoing IP addresses?