How DNS MX Records Work
A practical guide to mail routing, priority values, failover, and the mistakes that break delivery.
MX records tell sending mail servers which host should receive email for your domain.
Lower preference values are tried first, which is how MX records support ordered delivery and failover.
A correct-looking MX record still fails if its target hostname does not resolve with an A or AAAA record.
DNS MX records are one of the core pieces of email delivery. When someone sends mail to your domain, the sending mail server uses MX records to find out which server is responsible for accepting that message.
If your MX records are missing or misconfigured, email delivery can fail completely. That makes them one of the most important DNS record types for any domain that handles email.
This guide explains what MX records are, how they work, how to configure them, and what to check when something goes wrong.
What Are DNS MX Records?
An MX record, short for Mail Exchanger record, is a DNS record that tells other mail servers where email for your domain should be delivered.
If someone sends a message to user@example.com, the sender’s mail server looks up the MX records for example.com. DNS responds with the hostname or hostnames of the mail servers that accept mail for that domain.
Mail transfer agents, or MTAs, depend on MX records because they need a clear delivery target. Without valid MX records, mail may have nowhere to go.
How MX Records Work
When an email is sent, the sending mail server performs a DNS lookup for the recipient domain’s MX records. The result is a list of mail server hostnames, each with a preference value.
Lower numbers mean higher priority. For example:
10 mail1.example.com
20 mail2.example.com
In that setup, sending servers try mail1.example.com first. If it cannot accept the message, they fall back to mail2.example.com.
That allows redundancy and failover, but it is important to remember that standard MX records use preference ordering, not weight-based load balancing.
MX records point to hostnames, not IP addresses
An MX record should point to a hostname such as mail.example.com, not directly to an IP address.
example.com → MX → mail.example.com
mail.example.com → A / AAAA → IP address
If the hostname named in the MX record does not resolve properly, mail delivery breaks even if the MX entry itself looks correct.
Multiple MX Records and Redundancy
A domain can publish multiple MX records so delivery continues even if one mail server is unavailable.
This is commonly used for:
- primary and backup mail servers
- provider redundancy
- mail continuity planning
The server with the lowest preference value is tried first. Higher-numbered servers act as backups if earlier servers fail.
How to Configure MX Records
To add or change MX records, sign in to your DNS provider’s control panel and edit the DNS zone for your domain.
A basic MX record usually includes:
- Host / Name: often @ for the root domain
- Type: MX
- Priority / Preference: a number such as 10 or 20
- Value / Target: a mail server hostname such as mail.example.com
If you use a hosted provider such as Google Workspace or Microsoft 365, use the exact values they publish rather than improvising your own.
Modifying or Removing MX Records
You may need to update MX records when changing email providers, adding a backup mail server, retiring an old host, or correcting a bad configuration.
When replacing old MX records, make sure the new mail server is fully ready before deleting the old one. Otherwise, incoming mail may be rejected or misrouted.
Also remember that DNS changes are not always visible immediately. DNS caching and TTL settings can delay full propagation.
Common MX Record Problems
Some of the most common issues include:
- MX records pointing to the wrong hostname
- MX records pointing to a hostname with no A or AAAA record
- old MX records left behind after a provider switch
- incorrect preference values
- mail server connectivity or firewall issues
- DNS propagation delays after changes
It also helps to remember that valid MX records do not guarantee good inbox placement by themselves. SPF, DKIM, and DMARC still affect whether mail is trusted and accepted.
How to Troubleshoot MX Records
You can verify MX records using tools such as dig, nslookup, or online DNS lookup tools.
A basic check with dig looks like this:
dig example.com MX
Then verify that each mail server hostname resolves properly:
dig mail.example.com A
dig mail.example.com AAAA
If the hostname does not resolve, the MX record will not work properly.
A simple troubleshooting flow
- Check the MX records for the domain.
- Confirm the MX targets are hostnames, not IP addresses.
- Check that each hostname resolves with A or AAAA records.
- Confirm the mail server is reachable and accepting mail.
- Review SPF, DKIM, and DMARC if mail arrives but is rejected or spam-foldered.
Best Practices for MX Records
- Use the exact values your mail provider gives you.
- Point MX records to hostnames, not IP addresses.
- Make sure the target hostnames resolve correctly.
- Use backup MX records only when you actually need them.
- Test after every DNS change.
- Configure SPF, DKIM, and DMARC alongside MX records.
- Document your DNS settings for future changes.
Frequently Asked Questions
These are the practical questions people usually have when they first start working with MX records.
What do MX records actually do?
They tell sending mail servers which host should receive email for your domain.
Do MX records point to IP addresses?
No. They should point to hostnames, and those hostnames must then resolve through A or AAAA records.
What does the MX priority number mean?
It controls delivery order. Lower numbers are higher priority and are tried first.
Do multiple MX records mean load balancing?
Not in the usual weighted sense. Their main purpose is ordered delivery and failover.
Can mail still fail if the MX record looks correct?
Yes. Delivery can still fail if the target hostname does not resolve, the mail server is unreachable, or other email settings are wrong.
Why should I use my provider’s exact MX values?
Because even small mistakes in mail routing can break delivery completely.
Are MX records enough for healthy email delivery?
No. They are only one part of the setup. SPF, DKIM, and DMARC also matter for trust and deliverability.
What is the fastest first troubleshooting step?
Check the MX records with dig, then verify that each MX hostname resolves correctly with A or AAAA records.
Conclusion
MX records are a fundamental part of email routing. They tell the rest of the internet which mail servers should receive email for your domain, and in what order those servers should be tried.
If your MX records are correct, your mail has a clear destination. If they are wrong, delivery can become unreliable or fail completely.
MX records are only one part of a healthy mail setup, but they are the starting point. Get them right first.
Comments