
What Is an MX Record? How to Add and Check It
MX record explained: what it does, how priority works, how to add MX records at your DNS provider and how to check them with dig, nslookup or PowerShell.
Merve Arslan
WordPress & Hosting Expert
Your new business mailbox is ready, you can send messages, but nothing arrives. Or you switched email providers and half your mail still lands in the old inbox. In both cases the culprit is usually the same small DNS entry: the MX record.
This guide explains what an MX record is and how mail servers use it, what the priority number really does, how to add MX records at any DNS provider, and how to check them from the command line. We also cover the mistakes that cause bounces such as "MX record host unresolvable", and what to do with domains that should never receive mail.
What Is an MX Record?
An MX (Mail Exchanger) record is a DNS record that tells the world which servers accept email for your domain. When someone sends a message to [email protected], their mail server does not look at your website's address. It asks DNS: "What are the MX records for example.com?" and then connects to the host it gets back on port 25.
A typical MX record looks like this in a zone file:
; name TTL class type priority mail server
example.com. 3600 IN MX 10 mx1.mailprovider.net.
example.com. 3600 IN MX 20 mx2.mailprovider.net.
Each record has four parts that matter:
- Name (host): the domain that receives mail. In most panels this is
@or left empty for the root domain. - TTL: how long resolvers may cache the answer, in seconds.
- Priority (preference): a number that sets the order in which servers are tried.
- Target: the hostname of the mail server. It must be a hostname, never an IP address.
If a domain has no MX record at all, RFC 5321 tells sending servers to fall back to the domain's A or AAAA record. That fallback is why some misconfigured domains receive mail "by accident", and why domains that should not receive mail need an explicit null MX (more on that below).
How MX Priority Works
The priority number is often misunderstood. Lower number means higher preference. A sending server tries the record with the lowest number first and only moves to the next one if that server cannot be reached.
| Setup | Example records | What happens |
|---|---|---|
| Single server | 10 mx1.provider.net. | All mail goes to one host |
| Primary + backup | 10 mx1... and 20 mx2... | mx2 is used only if mx1 does not answer |
| Equal priority | 10 mx1... and 10 mx2... | Senders pick randomly, spreading load |
| Single hostname, many servers | 1 smtp.google.com. | Redundancy handled behind one name |
| Null MX | 0 . | Domain accepts no email at all |
The actual numbers do not matter, only their order. 10/20 behaves exactly like 1/5. Use the values your email provider gives you; they are chosen to match how their servers are built.
Warning: Do not add a "backup MX" from a different company unless it is set up to accept mail for your domain and filter spam. Spammers deliberately target lower-preference servers, and a backup that accepts everything can bypass your main provider's filters.
How to Add an MX Record
The steps are the same at almost every DNS provider, even if the buttons look different:
- Find where your DNS is hosted. Run
dig NS example.com +short. The answer tells you whose panel you need to log in to; it may not be the company you bought the domain from. - Remove old MX records that belong to a previous provider. Mixing two providers' MX records splits your mail between them.
- Add the new records using the values from your email provider: host
@, typeMX, priority, and target. - Set a reasonable TTL. 3600 seconds is a good default. Lower it to 300 a day before a planned migration so the switch spreads faster.
- Save and verify with the commands in the next section.
Panels label the fields differently. Here is how the same record usually maps:
| Field | Common labels | Value for the root domain |
|---|---|---|
| Name | Host, Name, @ | @ or empty (some panels want example.com) |
| Type | Type, Record type | MX |
| Priority | Priority, Preference, Pref | e.g. 10 |
| Target | Value, Points to, Mail server | e.g. mx1.provider.net |
| TTL | TTL | 3600 or Auto |
A few provider examples:
- Google Workspace: new setups use one record,
smtp.google.comwith priority 1. Older domains may still have the fiveaspmx.l.google.comrecords; Google supports both. - Microsoft 365: the admin center shows a tenant-specific hostname. Copy it exactly rather than guessing the format.
- Hosted Cloud corporate email: use the MX, SPF and DKIM values provided for your domain; if anything is unclear, 24/7 support can check the records with you.
Tip: Some panels automatically append your domain to the target. If you enter mx1.provider.net and the record ends up as mx1.provider.net.example.com, add a trailing dot (mx1.provider.net.) or check the panel's help page.
How to Check MX Records (MX Lookup)
You do not need an online tool to check MX records. Every operating system has one built in.
# Linux / macOS
dig MX example.com +short
# 10 mx1.mailprovider.net.
# 20 mx2.mailprovider.net.
# Ask specific public resolvers to see if the change has spread
dig @1.1.1.1 MX example.com +short
dig @8.8.8.8 MX example.com +short
# Ask your authoritative nameserver directly (bypasses all caches)
dig MX example.com @$(dig NS example.com +short | head -1) +short
# Make sure the MX target itself resolves
dig A mx1.mailprovider.net +short
On Windows:
nslookup -type=mx example.com
Resolve-DnsName -Name example.com -Type MX
If the authoritative server shows the new records but public resolvers still show the old ones, you are waiting for caches to expire. That takes at most the old TTL. If even the authoritative server shows the old values, the change was saved in the wrong panel.
To test that the mail server actually accepts connections, you can open an SMTP session:
openssl s_client -starttls smtp -connect mx1.mailprovider.net:25 -crlf -quiet
# Expect a "220 ..." greeting and certificate details; type QUIT to exit
Many home and office networks block outgoing port 25, so if this times out, try it from a server before assuming the mail host is down.
Common MX Record Mistakes
Most "email not arriving" tickets trace back to one of these:
- Pointing MX to an IP address. MX targets must be hostnames. Create an A record such as
mail.example.comand point the MX to that name instead. - Pointing MX to a CNAME. RFC 2181 forbids it, and some senders will reject or delay mail. The target must have its own A or AAAA record.
- "MX record host unresolvable". The hostname in the MX record does not resolve, usually because of a typo, a missing A record, or the domain-appending problem described above.
- Proxying the mail hostname. On Cloudflare and similar services, the A record your MX points to (for example
mail.example.com) must be DNS-only. Proxied records only carry web traffic. - Leftover records from the old provider. Two sets of MX records mean unpredictable delivery.
- Forgetting SPF and DKIM. MX only controls incoming mail. Outgoing mail needs SPF, DKIM and DMARC or it lands in spam. Our SPF, DKIM and DMARC guide covers those records.
MX Record vs Other Email DNS Records
MX is one of several DNS records involved in email. They do different jobs:
| Record | Type | Job |
|---|---|---|
| MX | MX | Where incoming mail for the domain is delivered |
| SPF | TXT on @ | Which servers may send mail for the domain |
| DKIM | TXT on selector._domainkey | Public key used to verify message signatures |
| DMARC | TXT on _dmarc | Policy for failed SPF/DKIM checks and reporting |
| Autodiscover / SRV | CNAME or SRV | Helps mail apps find server settings (optional) |
Domains That Should Not Receive Email
If a domain is only used for a website, or is parked, publish a null MX record as defined in RFC 7505. It tells senders to stop trying immediately instead of falling back to your web server's A record:
example.org. 3600 IN MX 0 .
example.org. 3600 IN TXT "v=spf1 -all"
The SPF record with -all adds the outgoing side: no server is allowed to send mail for this domain, which makes it less useful to spoofers.
Frequently Asked Questions
What does an MX record do?
An MX record tells sending mail servers which host accepts email for your domain. Without a correct MX record, incoming messages bounce or go to the wrong server.
Does a lower or higher MX priority number come first?
The lower number wins. Servers try the MX record with the lowest priority value first and move to higher values only if it does not respond. Records with equal values share the load.
How long do MX record changes take?
Your DNS provider usually publishes the change within minutes. Resolvers that cached the old record keep using it until its TTL expires, which is often one hour and at most a day or two.
Can an MX record point to an IP address?
No. An MX record must point to a hostname that has its own A or AAAA record. If you only have an IP, create a record such as mail.example.com and point the MX to that name.
How do I check my MX records?
Run dig MX example.com +short on Linux or macOS, or nslookup -type=mx example.com on Windows. To bypass caches, query your domain's authoritative nameserver directly.
Do I need MX records for a subdomain?
Only if the subdomain receives email, for example support.example.com. MX records apply to the exact name they are set on, so the root domain's records do not cover subdomains.
Conclusion
An MX record is a short DNS entry with a big job: it decides where your incoming email goes. Point it to a hostname rather than an IP or CNAME, remember that the lowest priority number is tried first, remove the previous provider's records when you switch, and verify the result with dig or nslookup against both public resolvers and your authoritative nameserver. Pair it with SPF, DKIM and DMARC and both sides of your email, incoming and outgoing, are covered. If you are choosing a provider as well, our business email hosting guide compares the options, and the email migration guide shows how to switch without losing messages.
Set up email on your own domain without the guesswork
Hosted Cloud corporate email costs $19.99 per month for 10 accounts, and our 24/7 support team answers within 15 minutes if your DNS records need a second look.
Merve Arslan
WordPress & Hosting Expert
Creating guide content on WordPress performance optimization, hosting selection, and e-commerce infrastructure.
Comments coming soon