An MX record, short for mail exchanger, is the DNS record that tells the rest of the internet where to deliver email for a domain. When someone writes to [email protected], their mail server asks DNS for the MX records of example.com, picks the one with the lowest priority number and hands the message to that server over SMTP.
MX records decide where mail arrives and nothing else. Whether the mail a domain sends is trusted is the job of SPF, DKIM and DMARC, which SPF, DKIM and DMARC explained covers. MX records are also what you change to move email to a new provider, and the record that loses mail when that move goes wrong.
How do MX records work?
RFC 5321, the SMTP standard, sets out what a sending server does with them:
- It looks up the MX records of the domain after the
@. - It sorts them by priority, lowest first. Records that share a number go in random order, which RFC 5321 requires so that those servers share the load.
- It connects to the first host on port 25, at the addresses in that host's A and AAAA records. If the host cannot be reached, the sender moves on to the next one.
- It queues the message when every host fails and tries again later. RFC 5321 asks for at least 30 minutes between attempts and at least four to five days before the sender gives up and bounces it.
You can run the first step yourself:
$ dig MX example.com +noall +answerexample.com. 3600 IN MX 10 mx1.example.com.example.com. 3600 IN MX 20 mx2.example.com.On Windows, nslookup -type=mx example.com, or Resolve-DnsName example.com -Type MX in PowerShell, gives the same answer. What happens once the sender connects is an SMTP conversation, which What is SMTP? follows command by command.
What happens when a domain has no MX record?
The sender falls back to the domain itself. RFC 5321 treats a domain with no MX records as if it had one at priority 0 pointing at its own name, an "implicit MX", and delivers to the domain's A or AAAA address. That address usually belongs to a web server, which refuses the connection or never answers, so the mail waits in queues for days before it bounces.
The fallback applies only when there are no MX records at all. Once a domain publishes MX records, senders reach it only through them, and when none of them is usable, RFC 5321 has the sender report an error rather than fall back.
What does an MX record look like?
In a zone file, an MX record is one line:
example.com. 3600 IN MX 10 mx1.example.com.| Part | In the example | What it means |
|---|---|---|
| Name | example.com. | The domain whose mail it routes. Mail to every address at that exact name follows it |
| TTL | 3600 | How many seconds resolvers may keep the answer before asking again |
| Class | IN | Internet, as on nearly every record |
| Type | MX | Mail exchanger, type 15 in RFC 1035 |
| Priority | 10 | A 16-bit number, so 0 to 65535, which RFC 1035 calls the preference. Lower numbers are tried first |
| Mail server | mx1.example.com. | The host name of a server that accepts mail for the domain |
Many DNS hosts give the priority a field of its own and fill in the class for you, so what you type is often just @ as the name, the priority and the server.
Rules for the mail server name
- It must be a host name, never an IP address. RFC 5321 expects the name to resolve to at least one A or AAAA record. To use a server you only know by its address, give it a name with an A record, such as
mail.example.com, and point the MX record at that name. - It must not be a CNAME. RFC 2181 says the value of an MX record "must not be an alias". A DNS server adds the mail server's addresses to its MX answer, but that extra step does not follow aliases, so senders have to ask again, and some give up.
- It may need a final dot. Some DNS hosts read a server name without one as a name inside your domain, so
mx1.example.netis saved asmx1.example.net.example.com. Enter it with the dot, or check what the host saved.
MX records also belong to one exact name. A subdomain such as mail.example.com is looked up on its own and gets none of the parent's records, so a subdomain that should receive mail needs MX records of its own.
How does MX priority work?
The priority only sets the order. A domain with records at 10 and 20 behaves exactly like one with records at 1 and 2, and a record at 0 is simply tried first. Microsoft 365 asks for its record at the highest priority your DNS host allows, typically 0, and Google Workspace for its single record at 1.
Records that share a number are equals, and senders shuffle them for every message, which spreads incoming mail across those servers.
One host name can also have several addresses, and RFC 5321 has senders work through those too. Google's single record names smtp.google.com, which answered our lookup on 10 November 2026 with two IPv4 and two IPv6 addresses.
Do you need a backup MX?
A second record at a higher number gives senders somewhere to go when the first server is down, which can be worth having for a domain that runs its own mail server. But senders already queue mail for days, so an outage of a few hours loses nothing even without one.
A backup also has to know which addresses exist and filter spam as carefully as the primary. A server that accepts a message takes on the job of delivering it, and RFC 5321 says that when it later cannot, it must mail a bounce to the envelope sender. A backup that accepts mail for any address at the domain ends up bouncing mail for addresses that never existed, often to senders that were forged. If a provider hosts your mail, publish exactly the records it gives you and add none of your own.
What is a null MX record?
A null MX says that a domain accepts no email. RFC 7505, published in June 2015, defines it as a single MX record with priority 0 and a lone dot as the server:
example.org. 3600 IN MX 0 .- It has to be the only MX record. A domain that publishes a null MX "MUST NOT advertise any other MX RR".
- Senders stop at once. Instead of trying the domain's own address and retrying for days, a sending system refuses the message straight away, with
556and the enhanced code5.1.10, "Recipient address has null MX". - Receivers may refuse mail from it. A server can reject mail whose sender domain publishes a null MX, with
550 5.7.27, "Sender address has null MX", because no reply or bounce could reach that domain.
That last point decides where it belongs. RFC 7505 says not to publish a null MX on a domain used in the envelope sender or the From address, so keep it for parked domains and names that neither send nor receive. Pair it there with the SPF record v=spf1 -all, which says the name sends no mail, as What is SPF? explains.
MX records for Google Workspace and Microsoft 365
As of November 2026, the two largest business mail providers ask for these:
| Provider | Priority | Mail server | Notes |
|---|---|---|---|
| Google Workspace | 1 | smtp.google.com | One record for domains set up since 2023. Older setups whose records start with aspmx still work. Google asks you to remove every other MX record |
| Microsoft 365 | The highest your DNS host allows, typically 0 | The value on the Add DNS records page of the admin center | A TTL of 3600 seconds. Exchange Online supports TTLs below six hours |
Copy the values from your provider's admin console, which wins wherever it differs from a table like this one. The MX record lookup lists the records of other common providers, such as Zoho, Proton and Fastmail, and shows what any domain publishes today.
How do you change MX records without losing mail?
- Create every mailbox and alias at the new provider first. Microsoft asks for users to be added before the MX record changes, so mail keeps working through the switch.
- Lower the TTL a day ahead. Resolvers may keep an answer for as long as its TTL, so drop the MX records to 300 seconds the day before and the old answer stops lingering.
- Update MTA-STS first, if you publish it. Senders in enforce mode deliver only to hosts the policy lists. RFC 8461 asks for the policy file to change before the
idin its TXT record, so add the new hosts to the file, then change theid, and keep the old hosts listed until the move is done. - Replace the records in one go. Delete every MX record of the old provider, then add the new ones. An old record left at a lower number keeps getting the mail, and one left at a higher number gets whatever the new servers miss, in mailboxes nobody reads.
- Keep the old mailboxes for a few days. Senders that still hold the old answer deliver to the old servers until it expires. Microsoft also points out that mail already received stays with the previous host unless you migrate it.
- Test from outside. Look the domain up again and send messages from an account at another provider. Google warns that new MX records can take up to 72 hours to be recognised.
- Raise the TTL again once mail reaches the new servers.
None of this touches the mail you send. The SPF, DKIM and DMARC records for the new provider are a separate change, and the deliverability checker shows whether they are in place.
MX records, SPF and the return path
MX records turn up in two other parts of an email setup.
SPF's mx mechanism authorises the addresses of a domain's MX hosts to send its mail. It suits a server that both receives and sends, but it costs one of SPF's ten DNS lookups, and What is SPF? explains why your provider's include is usually the better choice.
The return path often has MX records of its own. A sending service that puts the envelope sender on a subdomain of yours, such as bounce.example.com, needs that subdomain to receive the bounces and complaints sent back to it. Amazon SES, for example, asks for exactly one MX record at priority 10 on its custom MAIL FROM domain, pointing at its feedback host, and says that subdomain should be one you neither send from nor receive on. Because it lives on a different name, that record sits beside your mailbox provider's MX records without touching them.
Common questions about MX records
Do MX records affect sending email?
No. They decide where mail to your domain is delivered, and receivers judge the mail you send by SPF, DKIM and DMARC. The one exception is a return-path subdomain, whose MX record a sending service may need to collect bounces. If the mail you send lands in spam, Why are my emails going to spam? goes through the causes.
Can an MX record point to an IP address?
No. It has to name a host, and that host needs an A or AAAA record. Create a name for the address and point the MX record at the name.
Can an MX record point to a CNAME?
It must not. RFC 2181 rules out an alias as the value of an MX record, and some senders will not follow one, so use the final host name.
Can a domain have more than one MX record?
Yes, as many as it needs, and senders work through them by priority. Keep them all at one provider, unless a filtering service in front of your mailboxes is meant to receive first.
Do subdomains use the parent domain's MX records?
No. Each name is looked up on its own, so mail.example.com needs MX records of its own to receive mail.
How long does an MX change take?
As long as resolvers keep the old answer, which is the old record's TTL, often an hour. Google allows up to 72 hours for new records to be recognised, and lowering the TTL a day before a change shortens the wait.
What does MX priority 0 mean?
Nothing special. It is the lowest possible number, so that record is tried first.
Where Nextmail fits
When you add a domain to Nextmail, its page lists every record the domain needs, with two MX records among them. One, at priority 10 on the domain itself, brings its mail to Nextmail. The other sits on the return-path host, bounce. under your domain, with an SPF record beside it, so the envelope sender of your mail is on your own domain and bounces still find their way back. Verification checks two things: that the MX records bring mail to Nextmail, and that an ownership TXT record proves the domain is yours, which is needed because every domain Nextmail receives for points at the same MX hosts. The page then checks each record against public DNS, shows what it found and names the usual cause of a mismatch, such as a server name saved without its final dot.
With Cloudflare connected, one sync writes every record, the MX included, and replaces whatever was at those names, except that the SPF record keeps the senders it already lists. If the domain already receives mail somewhere else, its mail starts arriving in Nextmail from then on, so make sure you are ready before you press Sync. Connect a domain has the steps, and Multiple domains explains how each record is checked.
To leave a domain's MX records where they are, connect its mailboxes instead. A connected mailbox at Google Workspace, Microsoft 365 or another provider stays where it is, and nothing in DNS changes. For any domain, the MX record lookup lists its records in the order senders try them, with the addresses and reverse DNS behind each host, and flags a missing or null MX, hosts that do not resolve and records that point at an alias or an address. It also runs over the API, for checking domains from your own code.
Free tools
Try what you just read on your own setup. They are free and need no account.
References
- 1RFC 1035: Domain Names - Implementation and SpecificationIETF
- 2RFC 5321: Simple Mail Transfer ProtocolIETF
- 3RFC 2181: Clarifications to the DNS SpecificationIETF
- 4RFC 7505: A "Null MX" No Service Resource Record for Domains That Accept No MailIETF
- 5RFC 8461: SMTP MTA Strict Transport Security (MTA-STS)IETF
- 6Set up MX records for Google WorkspaceGoogle
- 7Connect your domain by adding DNS recordsMicrosoft
- 8Using a custom MAIL FROM domainAmazon Web Services
