What Is an MX Record?
An MX (Mail Exchange) record is a DNS entry that tells other mail servers which server should receive email for your domain. It points to a hostname, not an IP address directly, and includes a priority number so a domain can list backup mail servers in order.
What an MX record contains
An MX record has three parts beyond the domain itself: the record type (MX), a priority value (also called preference), and a mail server hostname. Lower priority numbers are tried first. A domain can have several MX records to list a primary mail server and one or more fallback servers.
example.com. MX 10 mail1.example.com.
example.com. MX 20 mail2.example.com.
Here, sending servers try mail1.example.com first because 10 is lower than 20, and fall back to mail2.example.com only if the first one is unreachable.
How MX records are used in email delivery
- Someone sends an email to
user@example.com. - The sending mail server looks up the MX records for
example.comin DNS. - It sorts the results by priority, lowest number first.
- It attempts to connect to that hostname's mail server over SMTP, usually on port 25.
- If the connection fails, it tries the next-lowest priority record, and keeps retrying the whole delivery for a period of time before giving up.
Common MX record mistakes
| Mistake | Effect |
|---|---|
| Pointing MX to an IP address instead of a hostname | Invalid record; most DNS providers reject it or mail fails |
| Missing trailing dot in some DNS zone files | Hostname gets the zone appended, creating a wrong address |
| No A or AAAA record for the mail server hostname | Sending servers cannot resolve where to connect, delivery fails |
| Changing MX records without lowering TTL first | Old servers keep receiving mail during the DNS propagation window |
| Using a webmail-style address instead of the provider's MX hostname | Email never reaches the intended mailbox provider |
Setting up MX records for a common provider
When you switch email providers, for example moving to a third-party mailbox service, that provider gives you one or more MX hostnames and priority numbers to enter in your domain's DNS zone, usually through your domain registrar or DNS host's control panel. It is worth lowering the TTL (time to live) a day in advance so the change takes effect quickly, and keeping the old MX records active briefly during the transition avoids losing mail sent mid-change.
Frequently asked questions
What does an MX record do?
An MX record tells other mail servers which hostname should receive email for a domain, and in what order to try multiple mail servers if several are listed.
What is MX priority?
MX priority is a number that decides the order mail servers are tried, with lower numbers tried first. It lets a domain list a primary mail server and backup servers for when the primary is unreachable.
Can an MX record point to an IP address?
No. An MX record must point to a hostname, which in turn needs its own A or AAAA record to resolve to an IP address. Pointing an MX record directly at an IP address is not valid.
How long does it take for MX record changes to take effect?
It depends on the TTL (time to live) set on the previous record, which can range from minutes to 48 hours or more. Lowering the TTL a day before a planned change speeds up how quickly mail servers worldwide see the update.
Why is my email not working even though my website works fine?
Website traffic uses A or CNAME records, while email delivery depends entirely on MX records, so one can work while the other is broken. Check that the MX records point to the correct, currently active mail provider.
Can a domain have more than one MX record?
Yes, and it is common practice. Multiple MX records with different priorities provide redundancy, so email can still be delivered if the top-priority mail server is temporarily down.
Related topics
- What Is DNS (Domain Name System)? Domains & DNS
- What Is an IP Address? Networking & IP
- What Is an Email Server? Email Hosting
- SMTP vs. IMAP vs. POP3 Email Hosting
- What Is TTL (Time to Live) in DNS? Domains & DNS