What is an MX record? How email finds your domain
Kofi Agyem, Founder and CEO, CloudzyroPublished · 6 min read
On this page
- 1. The short answer
- 2. How email delivery uses MX records
- 3. What an MX record looks like
- 4. MX records for common email providers
- 5. MX's partners: SPF, DKIM and DMARC
- 6. A worked example: a site and email on one domain
- 7. Changing email providers without losing mail
- 8. Null MX: saying a domain gets no email
- 9. Common mistakes
- 10. How to check your MX records
- 11. Sources
MX records tell the internet which servers receive email for your domain. How they work, what priority means, common examples and how to check yours.
1. The short answer
An MX (mail exchanger) record is a DNS record that tells the world which servers receive email for your domain. When someone sends a message to you@example.com, their mail server looks up the MX records for example.com and delivers to the server listed there. Each MX record has a priority number: lower numbers are tried first.
MX records only handle incoming mail. Proving that mail from your domain is genuine is the job of TXT records (SPF, DKIM and DMARC), covered below. New to DNS? Start with What is DNS?.
2. How email delivery uses MX records
- Someone sends an email to
hello@mybakery.com. - Their mail server asks DNS for the MX records of
mybakery.com. - DNS answers with one or more mail server names and their priorities.
- The sending server looks up the address of the server with the lowest number and connects to it.
- If that server doesn't answer, it tries the next, and keeps retrying for a while (often days) before giving up and bouncing the message.
If a domain has no MX records at all, the standard says senders may fall back to the domain's A record and try to deliver there. That's rarely what you want, which is why domains that don't receive mail should say so (see null MX below).
3. What an MX record looks like
example.com. 3600 IN MX 10 mx1.mailprovider.example.
example.com. 3600 IN MX 20 mx2.mailprovider.example.- Name: the domain that receives the mail, here
example.com(shown as@in most dashboards). A subdomain likesupport.example.comcan have its own MX records. - Priority:
10and20. Lower is preferred, somx1is tried first. The numbers themselves don't matter, only their order. Equal numbers share the load. - Target: the mail server's host name. Never an IP address, and never a name that's a CNAME.
- TTL:
3600seconds, how long resolvers may cache it.
4. MX records for common email providers
Always copy the exact values your provider shows in its setup screens, because they can change and some are unique to your domain. As a guide to what to expect:
- Google Workspace: new setups usually get a single MX record,
smtp.google.comwith priority 1. Older setups use five records (aspmx.l.google.comand others). - Microsoft 365: one MX record pointing to a name unique to your domain, like
example-com.mail.protection.outlook.com, with priority 0. - cPanel hosting: mail usually goes to the hosting server itself. With Cloudzyro Web Hosting, the domain's records are managed in cPanel's Zone Editor, and mailboxes are reached at
falcon.cloudzyro.com.
5. MX's partners: SPF, DKIM and DMARC
Receiving mail needs MX records. Getting your own mail delivered, rather than marked as spam, needs three TXT records. Large mailbox providers such as Gmail and Yahoo now require them from anyone sending in bulk, and they help everyone else's mail too.
- SPF (a TXT record on
@startingv=spf1) lists the servers allowed to send mail for your domain. Only one SPF record is allowed per name: if two services each give you one, merge them into a single record. - DKIM (a TXT or CNAME record with a name your provider gives you, like
google._domainkey) publishes a key that proves messages weren't altered and really came from your domain. - DMARC (a TXT record on
_dmarc) tells receivers what to do when SPF and DKIM checks fail, and where to send reports.
@ TXT "v=spf1 include:_spf.google.com ~all"
_dmarc TXT "v=DMARC1; p=none; rua=mailto:dmarc@example.com"6. A worked example: a site and email on one domain
Priya's bakery site runs on Cloudzyro Sites & Apps at www.risebakery.co.uk, and her email is with Google Workspace. Her records:
Type Name Value Priority
CNAME www domains.cloudzyro.app
A @ 173.234.137.167
MX @ smtp.google.com 1
TXT @ v=spf1 include:_spf.google.com ~allThe website records (www and the A record on @) and the email records (MX and TXT) sit side by side without interfering. Moving the website to another host only changes the first two. Email keeps flowing.
She bought the domain in Cloudzyro Domains and pointed it at her site, so the website records are set for her. She added the MX and TXT records under Email records on the domain's page. See Add email records to a domain.
7. Changing email providers without losing mail
- Set up the new provider first: add your domain there and create the mailboxes.
- A day ahead, lower the TTL on your current MX records to 300 seconds, so the switch takes effect quickly.
- Add the new provider's verification TXT record and let it confirm the domain.
- Replace the old MX records with the new ones, and update SPF to include the new provider. Add its DKIM record.
- Keep the old mailboxes open for a few days. Mail sent by servers that still had the old records cached lands there, so check them and move anything you need.
8. Null MX: saying a domain gets no email
If a domain never receives email, publish a null MX record (RFC 7505): a single MX with priority 0 and a target of .. Senders then bounce mail straight away instead of retrying. Pair it with an SPF record that allows nobody to send, so others can spot mail that fakes your domain.
@ MX 0 .
@ TXT "v=spf1 -all"9. Common mistakes
- Changing nameservers without copying MX records. The new provider starts empty, and email stops arriving. Copy every MX and TXT record before you switch.
- Pointing MX at an IP address or a CNAME. Use the host name your provider gives.
- Leftover records from an old provider. An old MX with a lower number can catch mail you expected elsewhere. Remove records you no longer use.
- Two SPF records. Receivers treat that as an error. Merge them.
- A CNAME on `@`. It's not allowed alongside MX records. See A record vs CNAME.
10. How to check your MX records
# MX records, with priorities
dig +short MX example.com
# SPF and other TXT records
dig +short TXT example.com
# DMARC
dig +short TXT _dmarc.example.com
# Windows
nslookup -type=MX example.comYou should see each mail server with its priority, like 1 smtp.google.com.. Nothing at all means no MX records, or that you're looking at the wrong nameservers (dig +short NS example.com tells you which ones hold the domain's records). Most email providers also have a check button in their setup screens.