What Is an MX Record? How Email Finds Your Domain
Quick answer
An MX (mail exchange) record is a DNS record that tells other mail servers where to deliver email for your domain. It points to a mail server's hostname and includes a priority number; lower numbers are tried first. Without correct MX records, email sent to [email protected] won't arrive.
How MX records work
When someone sends an email to [email protected], their mail server needs to know where to deliver it. It looks up the MX records for example.com in DNS, gets back a list of mail servers, and connects to them in priority order.
A typical set of MX records looks like this:
| Name | Type | Priority | Value |
|---|---|---|---|
| @ | MX | 10 | mx1.mailprovider.com |
| @ | MX | 20 | mx2.mailprovider.com |
- Name:
@means the root domain, so this applies to addresses ending in @example.com. - Priority (sometimes called preference): lower numbers are tried first.
- Value: the hostname of the mail server, supplied by your email provider.
What MX priority means
The priority number decides the order in which sending servers try your mail servers.
| Setup | What happens |
|---|---|
| One record, priority 10 | All mail goes to that server |
| Priority 10 and 20 | Senders try 10 first and fall back to 20 if it’s unavailable |
| Two records both at priority 10 | Senders spread mail across both |
The actual numbers don’t matter, only their order. Some providers now use a single MX record, while others give you several. Use exactly what your provider specifies.
If the primary server is unreachable and there’s no backup, most sending servers don’t give up straight away. They queue the message and retry for a period, often a few days, before bouncing it.
When you need to set up MX records
- Setting up business email with a provider such as Google Workspace, Microsoft 365, Zoho Mail or Fastmail. See how to set up business email.
- Switching email providers.
- Moving your DNS to a new provider by changing nameservers. Your MX records must come with it.
- Using email on a subdomain, such as support.example.com, which needs its own MX records.
How to add MX records
- Get your provider’s MX values. Your email provider’s setup guide lists the hostnames and priorities.
- Log in to your DNS provider. This is wherever your nameservers point, often your registrar.
- Remove old MX records that belong to a previous provider or your registrar’s default email forwarding, unless your new provider says otherwise.
- Add each new MX record: type MX, name
@(or blank), the priority and the mail server hostname. - Add the email authentication records your provider gives you: an SPF TXT record, a DKIM record and ideally a DMARC record. See SPF, DKIM and DMARC explained.
- Save and verify in your email provider’s dashboard. Most providers check the records and confirm when they’re live.
- Send a test email from an outside account, such as a personal email address, and check it arrives.
Switching email providers without losing mail
Changing MX records doesn’t move your old emails; it changes where new mail is delivered. To switch smoothly:
- Set up mailboxes at the new provider first.
- Lower the TTL on your current MX records a day or so ahead, if your DNS provider allows it.
- Change the MX records.
- Keep the old account open for a few days, as some senders may still deliver there while cached records expire.
- Migrate old mail using your new provider’s import tools.
Common MX mistakes
- Mixing records from two providers. Leftover MX records from an old provider can send some mail to the wrong place.
- Pointing MX at an IP address. It must be a hostname.
- Pointing MX at a CNAME. The DNS standards say the target should have its own address records.
- Typing the domain twice, such as mx1.mailprovider.com.example.com. Some dashboards append your domain unless the value ends with a dot; follow your provider’s instructions.
- Forgetting MX after a nameserver change. One of the most common reasons email suddenly stops.
How to check your MX records
Use an online MX lookup tool, or from a terminal:
dig example.com MX +short
nslookup -type=mx example.com
The results should list only your current provider’s servers. If you see old entries, remove them at your DNS provider.
The “null MX” record
If a domain should never receive email, you can publish a single MX record with priority 0 and a value of .. This tells senders not to try. It’s useful for domains you own only to protect a brand.
Frequently asked questions
Can I have MX records for two email providers at once?
Not in a useful way. Senders deliver to whichever server has the best priority, so mail would be split unpredictably. Use one provider's MX records for each domain or subdomain.
Do MX records affect my website?
No. MX records only control incoming email. Your website is routed by A, AAAA and CNAME records, so you can host your site and email with different companies.
Can an MX record point to an IP address?
No. It must point to a hostname, and that hostname needs its own A or AAAA record. It also shouldn't point to a CNAME.
Do MX records control outgoing email?
No. MX records only handle incoming mail. Outgoing mail is authenticated with SPF, DKIM and DMARC records, which are TXT records.
Sources