DNS MX Record

DNS MX Record Definition
A DNS MX (Mail Exchange) record tells email servers where to deliver messages for a domain. When you email someone, your mail server uses DNS to look up the recipient’s MX record. The MX record tells your mail server where to send your message via SMTP (Simple Mail Transfer Protocol), which is the standard protocol for sending emails over the internet. MX records are important, whether you host your email or lease it from a hosted provider like Zoho or Google Workspace—without them, the server may not always deliver your message to the right place.
A simple way to understand MX records is to use the mailroom analogy. Think of your domain as an office building and of your mail server as the building’s mailroom. An MX record acts like a note at the entrance, telling mail carriers where the mailroom is so they know where to deliver incoming mail.
DNS MX Record Example
The easiest way to understand how MX records work is to look at a common MX record example and see what each record component does.
Domain Name | Record Type | Priority | Mail Server | TTL |
example.com | MX | 10 | mail1.example.com | 86400 |
example.com | MX | 20 | mail2.example.com | 86400 |
Here’s what each record component means:
- Domain name: Specifies which domain the MX record handles email delivery for.
- Record type: Defines the DNS record type (in this case, an MX record).
- Priority: Determines which mail server is used first. The lower the value, the higher the priority.
- Mail server: Represents the mail server that receives incoming emails for the domain.
- TTL (Time to Live): Tells DNS servers how long to cache the MX record before they check for an update. TTL is measured in seconds. So, if it’s set to 86,400 seconds, DNS servers will refresh the record after 24 hours.
How Do DNS MX Records Work?
This is what happens in the background when you send an email:
- The MTA (Message Transfer Agent) responsible for transferring emails sends a DNS query to the MX record for the receiver’s domain.
- The MX record tells the MTA which mail servers handle incoming emails for the domain.
- The MTA then establishes an SMTP connection to the domain’s mail servers, prioritizing the server with the lowest value.
- Finally, your email reaches the recipient.
What Is a Backup DNS MX Record?
An MX record backup is a mail server with a higher priority value, which means MTAs don’t prioritize it. The backup server automatically handles email delivery if the primary server stops running.
In our example, mail1.example.com, with a priority of 10, is the primary mail server. mail2.example.com, with a priority of 20, is the backup.
DNS MX Record vs Other DNS Records
MX records are part of DNS, alongside other records:
DNS Record Type | DNS Record Purpose |
MX record | Sends mail to the right mail servers. |
A record | Contains the IPv4 address for a domain. |
AAAA record | Holds the IPv6 address for a domain. |
CNAME record | Maps one domain name to another. |
TXT record | Lets domain administrators store text notes in the record, usually for email security. |
NS record | Includes the name server associated with a DNS entry. |
SOA record | Stores important information about a domain, like admin email addresses. |
SRV record | Specifies a host and port for specific services, like instant messaging. |
PTR | Provides the domain name associated with an IP address. |
Common DNS MX Record Issues
Here are various MX record issues that could cause delays or emails to bounce:
- MX records pointing to a CNAME: This results in delivery failures, as MX records must either point to an A or AAAA record that contains the mail server’s IP address.
- Incorrect priority values: The primary mail server must have the highest priority (the lowest number). If not, emails will go to backup mail servers, resulting in delays.
- Outdated mail server IPs: If your mail server IP address changes, you must update the appropriate DNS records (A or AAAA). Otherwise, emails won’t reach your mail servers.
- Misconfigured backup servers: A backup server must have the same configuration as a primary server—the only exception is the priority value. If you don’t configure the backup server properly, it won’t receive emails if your primary server goes down.
- Delayed DNS updates: When you update an MX record, it might take up to 48 hours for the changes to take effect. During that period, email delivery could fail.
Read More
FAQ
An MX record tells email servers where to send emails for a domain using SMTP (Simple Mail Transfer Protocol). Basically, when you send an email, your mail server queries the recipient’s MX record to learn which mail servers receive incoming messages.
An MX record’s priority order determines which mail server receives your emails first. The lowest number represents the highest priority. So, a mail server with a value of 10 has higher priority than a server with a value of 20.
If an MX record is missing, your email won’t reach the recipient. The MX record tells your mail server’s MTA (Message Transfer Agent) which mail server receives emails for the recipient’s domain.
You should assign the lowest priority value to your main mail server to make sure it receives all emails first. If you have two mail servers, the main one should have a priority value of 0. The second server acts as the backup, so it should have a value of 10.
No, an MX record won’t store an IP address. Instead, it stores a domain name that points to a hostname, which is the readable name for a server or device. The hostname then resolves to an IP address via an A or AAAA record. If an MX record contains an IP address, most mail servers will ignore or reject it because they don’t see it as a valid hostname.