An MX record, short for Mail Exchange record, is a DNS record that tells sending mail servers which server accepts email for a domain. When someone emails you, their mail server looks up your domain's MX records, picks the one with the lowest priority number, and delivers the message to that server.
Key takeaways
- An MX record points email for a domain to a mail server hostname, never directly to an IP address.
- The lowest priority number is tried first; higher numbers are backups if the first server is down.
- Wrong or missing MX records cause bounced or lost mail, so check them before and after any email migration.
Every email you receive takes a short detour through DNS before it reaches your inbox. The record that controls that detour is the MX record, and getting it wrong is one of the fastest ways to lose mail silently.
What is an MX record?
An MX record, short for Mail Exchange record, is a DNS record that names the mail server responsible for accepting email for a domain. When someone sends you an email, their server looks up your domain's MX records to find where to deliver it.
Cloudflare explains that an MX record directs email to a mail server using SMTP. Think of your domain as a company building. The MX record is the sign in the lobby that tells the courier which mailroom to use. Without that sign, the courier has nowhere to leave the delivery.
The format is defined in RFC 1035, and its role in mail routing is spelled out in RFC 5321, the SMTP standard. A typical record looks like this: example.com. 3600 IN MX 10 mail.example.com.
Each part has a job. The name is the domain the record applies to, 3600 is the TTL in seconds, MX is the record type, 10 is the priority, and mail.example.com is the mail server hostname. The trailing dot marks it as a fully qualified domain name.
How does an MX record work?
When you send an email, your mail server does not already know where the recipient's inbox lives. It queries DNS for the recipient domain's MX records, then connects to the server those records name and hands over the message using SMTP.
The process has five steps. First, you send a message to someone at example.com. Second, your outgoing mail server, called a mail transfer agent, queries DNS for the MX records of example.com. Third, DNS returns every MX record, each with a priority value.
Fourth, your server picks the record with the lowest priority number, then looks up that hostname's A or AAAA record to get its IP address. Fifth, it opens an SMTP connection to that server and delivers the message.
If the first server does not answer, the sender tries the next MX record in priority order. If no server answers, the sender usually retries for a while, then bounces the message back to you with a delivery failure notice.
How does MX record priority work?
Priority, also called preference, is the number before the mail server hostname. The lowest number is tried first, so a server with priority 10 is preferred over one with priority 20. Equal numbers mean the sender can pick either one.
The numbers themselves do not matter, only their order. Google Workspace uses 1, 5, 5, 10 and 10. Another provider might use 10, 20 and 30 for the same setup. Both work the same way.
Multiple MX records give you failover. If your main mail server goes down for maintenance, senders automatically try the backup. A backup MX record is simply an MX record with a higher priority number, so it is only used when the preferred servers are unavailable.
Do not confuse priority with load balancing. Senders are not required to spread mail evenly across equal-priority servers, and most will try them in the order DNS returns them.
MX record vs SPF, DKIM and DMARC: what is the difference?
MX records get email to you. SPF, DKIM and DMARC decide whether mail claiming to be from you is trusted. They are separate records that work together, and a domain that sends and receives mail normally needs all of them.
| Record | What it does | Direction | If it is missing |
|---|---|---|---|
| MX | Names the server that receives your mail | Incoming | Mail bounces or is lost |
| SPF | Lists servers allowed to send mail for your domain | Outgoing | Your mail is more likely to be marked as spam |
| DKIM | Adds a cryptographic signature to outgoing mail | Outgoing | Receivers cannot verify your messages are genuine |
| DMARC | Tells receivers what to do with mail that fails SPF or DKIM | Outgoing | Attackers can spoof your domain more easily |
| A / AAAA | Maps a hostname to an IP address | Both | Your MX hostname cannot be reached |
MX records do not filter spam, scan messages or authenticate senders. They only route mail to the right destination. The authentication records then let receiving servers judge whether a message is legitimate.
Our guide to what DMARC is and how to set it up explains the authentication side in detail.
Our guide to what DKIM is covers the signing record that proves a message is genuine.
What do real MX records look like?
Every email provider publishes its own MX values, and you must copy them exactly from your provider. Two common examples show the pattern: a single-record setup and a five-record setup.
Google Workspace (Gmail)
New Google Workspace domains use a single MX record: smtp.google.com with priority 1. Older domains may still use five records, which Google still supports: aspmx.l.google.com at priority 1, alt1.aspmx.l.google.com and alt2.aspmx.l.google.com at priority 5, and alt3.aspmx.l.google.com and alt4.aspmx.l.google.com at priority 10.
If your mail already works on the five-record set, leave it alone. Do not mix the two sets, and do not add MX records from a previous provider alongside Google's.
Microsoft 365
Microsoft 365 gives each domain a single MX record that ends in mail.protection.outlook.com, with the first part unique to your domain. You copy the exact value from the Microsoft 365 admin center, because it differs for every tenant.
The pattern is the same everywhere: one or more hostnames, each with a priority, all supplied by your mail provider. Never guess these values from a blog post, including this one. Copy them from your provider's admin console.
How do I check my MX records?
You can check any domain's MX records in seconds with a free lookup tool. Enter the domain, run the check, and compare what comes back against the values your provider gave you.
Our free MX lookup tool shows the MX records for any domain, along with their priorities.
You can also use the DNS lookup tool to see the full set of records for a domain.
From a terminal, dig MX example.com or nslookup -type=MX example.com shows the same information. Look for three things: the hostnames match your provider, the priorities are in the right order, and every hostname resolves to an IP address.
Check before a migration, immediately after, and again 24 hours later. That catches typos early, while senders are still retrying, instead of after mail has started bouncing.
How do I set up an MX record?
Setting up an MX record means adding it at your DNS host, which is usually your domain registrar or your DNS provider. The exact clicks differ, but the steps are the same everywhere.
- Get the values from your mail provider. Copy the hostname and priority from your provider's setup page or admin console.
- Open your DNS settings. Log in to your registrar or DNS host and find the DNS or zone editor for your domain.
- Delete old MX records. Remove any MX records pointing at a previous provider, or some senders will keep trying them.
- Add the new MX record. Set the host to
@or leave it blank for the root domain, choose type MX, enter the priority, and paste the hostname. - Set a sensible TTL. 3600 seconds (one hour) is a common choice. Use a lower TTL, such as 300, in the days before a planned migration so changes spread faster.
- Save and verify. Run an MX lookup to confirm the new records are live, then send a test email from an outside account.
If your provider gives you several records, add all of them. If it gives you one, add just that one. Adding records from two providers at once splits your mail between them, which is almost never what you want.
What are the most common MX record mistakes?
Most MX problems come from a small list of errors, and most are easy to spot once you know what to look for.
- Pointing MX at an IP address. MX records must point to a hostname. An IP address here is invalid and mail will fail.
- Pointing MX at a CNAME. The RFCs forbid this. The MX target must resolve through an A or AAAA record directly.
- Leaving old records behind. After switching providers, old MX records send some mail to a server that no longer holds your mailboxes.
- Typos in the hostname. One wrong letter sends your mail to a server that does not exist, or worse, to someone else's server.
- Forgetting the TTL. A very long TTL means a mistake takes days to correct, because servers keep caching the wrong value.
What happens if a domain has no MX record?
If a domain has no MX record, most sending servers fall back to the domain's A record and try to deliver mail to the web server's IP address. That almost never works, because web servers do not accept mail, so the message bounces.
Some domains deliberately have no MX record because they never receive mail, for example a domain used only for sending transactional email. That is a valid choice, but it means replies to those messages will bounce.
A safer pattern for send-only domains is a null MX record, which explicitly tells senders that the domain accepts no mail. It is written as . MX 0 . in a zone file. This is cleaner than having no record at all, because senders get a clear answer instead of guessing.
The bottom line
An MX record is a small piece of DNS with an outsized job: it tells the whole internet where your email lives. Copy the values from your mail provider, keep the priorities in the right order, and verify with a lookup after every change.
Check your own domain now with the free MX lookup tool.
Then pair it with the DMARC checker to confirm your authentication records are in place too.
Frequently asked questions
What is an MX record in simple terms?
An MX record is a DNS entry that says which mail server should receive email for a domain. Without one, sending servers do not know where to deliver your mail, so messages usually bounce back to the sender.
What does MX priority mean?
Priority, also called preference, is the number in front of the mail server hostname. The lowest number is tried first. If that server does not answer, the sender tries the next lowest number, so higher numbers act as backups.
Can an MX record point to an IP address?
No. An MX record must point to a hostname, and that hostname must resolve to an A or AAAA record. It must not point directly to an IP address, and it must not point to a CNAME record.
How long do MX record changes take?
Changes can take anywhere from a few minutes to 72 hours to reach every mail server, because DNS records are cached. The TTL value on the record controls how long other servers cache the old value.
Do I need an MX record if I only send email?
No, you do not need one to send email, but you need one to receive it. A domain with no MX record can still send mail, though many receiving servers treat mail from such domains with extra suspicion.
What is the difference between an MX record and an SPF record?
An MX record routes incoming mail to your mail server. An SPF record tells other servers which servers are allowed to send mail from your domain. They do different jobs and a domain that sends and receives mail needs both.
Why is my email bouncing after changing MX records?
The most common causes are a typo in the mail server hostname, pointing the MX record at an IP address or a CNAME, old MX records from a previous provider left in place, or DNS changes that have not finished propagating yet.
Sources
The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.
Checked against Cloudflare's MX record documentation, RFC 5321 on SMTP mail routing, and Google Workspace MX values.
How we write and fact-check →