An MX record (mail exchanger record) is a DNS record that names the servers that accept incoming email for a domain. When someone sends a message to [email protected], their mail server looks up the MX records for example.com and delivers to the host with the lowest priority number first, falling back to the others if it is unavailable. Without a working MX record, a domain generally cannot receive mail reliably.
Each MX record has two parts: a priority (preference) number and a hostname. The hostname must itself resolve to an IP address through an A or AAAA record. MX records control only where incoming mail goes. They do not affect where you send from, which is governed by SPF, DKIM and the sending server's IP address.
How an MX record looks
example.com. 3600 IN MX 10 mx1.mailhost.example.
example.com. 3600 IN MX 20 mx2.mailhost.example.| Field | Meaning |
|---|---|
example.com. | The domain receiving mail. In many DNS panels the host field is shown as @ for the root |
3600 | TTL in seconds: how long resolvers may cache the answer |
MX | Record type |
10 | Priority (preference) |
mx1.mailhost.example. | The mail server hostname; the trailing dot marks a fully qualified name |
Panels differ. Some ask for the hostname with a trailing dot, some add it for you, and some append your domain if you omit it. Entering mx1.mailhost.example in a panel that appends the domain can produce mx1.mailhost.example.example.com, which is a common cause of mail failing. Check the saved result after you save. See registrar quirks.
How priority values work
The number is only a ranking. A sending server sorts the MX records by priority and tries the lowest first. If it cannot connect, or the server returns a temporary failure, it moves to the next. Records with the same number are equal, and senders spread attempts among them, which gives simple load sharing. The absolute value has no meaning, so 10 and 20 behave the same as 1 and 2.
| Setup | Example | Behaviour |
|---|---|---|
| One server | 10 mx.host.example | All mail goes there; if it is down, senders queue and retry |
| Primary and backup | 10 primary, 20 backup | Backup used only when the primary fails. See backup MX risks |
| Equal priority | 10 mx1, 10 mx2 | Senders spread mail between both |
| Hosted provider set | Provider specific values | Copy exactly what the provider gives you |
A backup MX that does not validate recipients can accept mail for addresses that do not exist and then bounce it later, which creates backscatter. Only add one if you know how it behaves, and remember that senders retry for days anyway.
How to check MX records
# Linux and macOS
dig +short MX example.com
# Query a specific resolver
dig +short MX example.com @1.1.1.1
# Windows and cross-platform
nslookup -type=MX example.com
# Confirm the target resolves
dig +short A mx1.mailhost.example
dig +short AAAA mx1.mailhost.exampleThe output lists priority and hostname, for example 10 mx1.mailhost.example.. Check three things: the right provider's hostnames are present, no old records remain, and every hostname has an A or AAAA record. If your results differ from the panel, you may be seeing a cached answer. Compare with an authoritative query, dig MX example.com @ns1.yourdns.example, using a nameserver from dig NS example.com. For wider DNS context see DNS records for email.
How to set MX records
- Get the exact MX hostnames and priorities from your mail provider. Do not guess or reuse an old provider's values.
- Open the DNS zone of your domain at the registrar or DNS host. Make sure you edit the zone that your nameservers actually serve.
- Delete the old MX records unless the provider says to keep them. Leftover records from a previous provider cause mail to split between two systems.
- Add each new record: type MX, host
@(or blank), the priority and the hostname. Set a TTL of 3600 or the provider's recommendation. - Save, then verify with
dig MXand a test message from an outside account. See adding DNS records at common DNS hosts.
Lower the TTL a day before a planned migration so changes take effect sooner, and raise it afterwards. See DNS TTL for email. Provider values for hosted mail change from time to time, so always take them from the provider's current documentation. For Google Workspace and Microsoft 365, see their MX records.
What happens when a sender looks up your MX
- The sending server asks DNS for the MX records of the recipient's domain.
- It sorts them by priority and resolves each target hostname to IP addresses.
- It connects to the first address on port 25 and starts the SMTP conversation with
EHLO. - If the connection fails or the reply is a temporary 4xx, it tries the next address or MX record, and later retries the whole list.
- If the reply is a permanent 5xx for the recipient, it stops and sends a bounce to the sender.
This is why a single missing A record or a typo in one MX hostname may not break everything immediately: mail flows through whichever entry works, and the fault shows up as delays or uneven delivery. Test every MX host individually. A short script that loops over the output of dig +short MX and runs a port 25 check on each host is a useful periodic monitor, as is alerting when the record set changes unexpectedly, because MX changes are a common step in domain hijacking.
Rules every MX record must follow
- The target must be a hostname, not an IP address.
- The target must not be a CNAME. RFC 2181 forbids pointing MX at an alias, and some senders fail on it. See CNAME versus A records.
- The target needs an A or AAAA record that resolves publicly.
- The server on that host must accept SMTP on port 25 from the internet and handle mail for your domain.
- If no MX record exists, senders fall back to the domain's A or AAAA record as an implicit MX. This works, but is better avoided because it is unclear and fragile.
- A domain that must never receive mail can publish a null MX,
0 ., defined in RFC 7505, which tells senders to stop immediately. See parked domains.
example.net. 3600 IN MX 0 .MX records and sending
MX records do not authenticate outgoing email. Receivers check SPF, DKIM and DMARC for that, and they check the sending IP's reverse DNS. Some systems also verify that the sender's domain has an MX or address record before accepting mail from it, which is why a domain that only sends should still have valid DNS. See sender domain not found errors and authenticating your sending domain.
Troubleshooting MX problems
| Symptom | Likely cause | Fix |
|---|---|---|
| Mail bounces with domain not found or no MX | No MX or A record, or wrong zone edited | Add MX records to the zone served by your nameservers |
| Some mail goes to the old provider | Old MX records still present, or cached | Remove them and wait for the old TTL to expire |
| Delivery fails with 5.4.4 unable to route | MX target does not resolve | Fix the A or AAAA record of the target |
| Mail delayed for hours | Primary down and backup misconfigured | Test each MX host on port 25. See email delay causes |
| Wrong hostname like host.example.example.com | DNS panel appended the domain | Edit the record and check the saved value |
| Dig shows records, mail still fails | Server not accepting the domain, or port 25 blocked inbound | Test with swaks. See command line SMTP tests |
Next steps
After the MX records are right, publish SPF, DKIM and DMARC for the domain, set reverse DNS on any servers you operate and test inbound and outbound mail. You can verify your records with the SPF, DKIM and DMARC checker. A shorter overview of the same topic is in MX records in brief.
Sending from your domain too? Verify the domain and send through authenticated SMTP on ports 587 or 465, separate from your inbound MX setup.
References and further reading
Frequently asked questions
What is an MX record?
It is a DNS record that lists the mail servers responsible for receiving email for a domain, each with a priority number.
What does MX priority mean?
Senders try the lowest number first and move to higher numbers if it fails. Equal numbers share mail between servers.
How do I check my MX record?
Run dig +short MX yourdomain.com or nslookup -type=MX yourdomain.com, and confirm the hostnames and priorities match your provider.
Can an MX record point to an IP address or a CNAME?
No. It must point to a hostname that has an A or AAAA record, and it must not be an alias.
Do I need an MX record to send email?
Not strictly, but a domain should have valid DNS, and you need MX records to receive replies and bounces on that domain.