DNS MX Record Overview

MX Records: Boost Email Reliability with Proper Configuration. Avoid MX to CNAME Redirects.
Have you ever wondered how email communication works over the internet?

Every day, billions of messages are sent through web-based services such as Gmail, Yahoo, and Outlook.

All these platforms use a protocol called DNS MX Record for routing emails from one server to another. This technique can be used by companies—both large and small—that prefer secure, cost-effective networks for their online operations.

In this blog post, we'll take a look at what' s an MX record is in layman's terms and understand the basics behind it: what it does, why it's important, and how to query one easily.

What is MX Record?

An MX record, which stands for "Mail Exchanger" record, is a type of DNS (Domain Name System) record used to specify the mail servers responsible for receiving email messages on behalf of a domain.

MX records are essential for properly routing email messages across the internet. When someone sends an email to an address associated with a domain (e.g., user@example.com), the recipient's email server uses MX records to determine where to deliver the email.

MX records allow domain administrators to specify multiple mail servers, each with its priority, which provides redundancy and load balancing for email delivery. If a higher-priority mail server is unreachable or experiencing issues, lower-priority servers can handle the email delivery.

Example of DNS MX Records

DNS MX (Mail Exchanger) records are essential to the Domain Name System (DNS) that helps route email messages to their intended destinations. These records are crucial for email communication across the internet.

When you send an email to someone, your email server relies on MX records to determine where to deliver that message. MX records specify the mail servers responsible for receiving and handling email for a particular domain. These records include information about the server's hostname or IP address and a priority value, which helps determine the order in which mail servers should be used for email delivery.

MX records are especially useful in ensuring email delivery reliability. Domain administrators can establish failover mechanisms by designating multiple mail servers with different priorities. If the primary mail server becomes unavailable, the sending email server will attempt to deliver the email to the next available mail server with a lower priority.

This redundancy helps ensure that email messages reach their recipients even in cases of server outages or network issues.

Now, let's proceed with the example of DNS MX records for the domain "example.com":

1- MX Record 1:
  • Priority: 10
  • Mail Server: mail1.example.com

2- MX Record 2:
  • Priority: 20
  • Mail Server: mail2.example.com

In this example:
  • The domain "example.com" has two mail servers specified in its MX records.
  • "mail1.example.com" is the primary mail server with a priority of 10, which means it is the preferred server for receiving email.
  • "mail2.example.com" is the secondary mail server with a lower priority of 20, indicating that it should be used if the primary server is unavailable.

When someone sends an email to an address within the "example.com" domain, the sender's email server will query the DNS records for "example.com" and retrieve these MX records.

It will then attempt to deliver the email to "mail1.example.com" first due to its lower priority. If "mail1.example.com" is unreachable for any reason, the sender's server will fall back to delivering the email to "mail2.example.com."

This setup provides redundancy and ensures that email can still be delivered even if the primary mail server experiences issues.

How About Querying an MX Record?

Querying an MX record involves using DNS tools or commands to look up the MX records associated with a specific domain. You can perform MX record queries using various methods and tools, depending on your operating system and preferences. Here are examples of how to query an MX record using the command line and some DNS-related tools:

1. Using the "nslookup" Command (Windows):
On Windows, you can use the "nslookup" command to query MX records. Open a command prompt and type the following:

nslookup -type=MX example.com

Replace "example.com" with the domain you want to retrieve MX records. This command will display the MX records associated with the specified domain.

2. Using the "dig" Command (Linux/macOS):
On Linux and macOS, the "dig" (Domain Information Groper) command is commonly used for DNS queries. To look up MX records, open a terminal and run the following command:

dig MX example.com

Again, replace "example.com" with the domain name you want to query. The "dig" command will provide detailed information about the MX records associated with the specified domain.

3. Using Online DNS Lookup Tools:
You can use online DNS lookup tools if you prefer a graphical interface or don't have access to a command line. Many websites and online services allow you to perform DNS queries, including MX record lookups.

Simply visit one of these websites, enter the domain name, and select the DNS record type as "MX" to retrieve the MX records.

Keep in mind that the specific tools and commands available to you may vary depending on your operating system and configuration.

MX record queries are helpful when you need to verify the mail servers responsible for receiving email for a particular domain or troubleshoot email delivery issues.
Improve your email deliverability with Unfiltered.ai

What is a Backup MX Record?

A Backup MX (Mail Exchanger) record, also known as a secondary MX record, is an MX record with a higher priority value (lower numerical value) than the primary MX record for a domain.

These records provide redundancy and ensure email delivery even when the primary mail server is temporarily unavailable or experiencing issues.

Here's how Backup MX records work:

  1. Primary MX Record: The primary MX record specifies the preferred mail server responsible for receiving and processing email messages for a domain. It has the lowest priority value (e.g., priority 10).
  2. Backup MX Record: The Backup MX record specifies a secondary mail server or servers with a higher priority value (e.g., priority 20 or higher). These servers are designated to handle email delivery if the primary mail server is unavailable.

When someone sends an email to an address within the domain, the sender's email server first queries the DNS records for that domain and retrieves the MX records. It then attempts to deliver the email to the mail server listed in the primary MX record.

If the primary server is reachable and operational, the email is delivered. However, if the primary server is unreachable or experiencing issues, the sender's server returns to attempting delivery to the mail server(s) listed in the Backup MX record(s).

Backup MX records ensure that email messages are not lost if the primary mail server is temporarily offline due to maintenance, network problems, or any other issues. The Backup MX servers temporarily hold incoming email messages until the primary mail server becomes available again.

Once the primary server is back online, it will retrieve the stored email messages from the Backup MX servers for further processing and delivery to the recipient's mailbox.

Can MX Records Point to a CNAME?

MX (Mail Exchanger) records cannot directly point to a DNS CNAME (Canonical Name) record. According to DNS standards (RFC 2181), MX records must point to A (IPv4 address) or AAAA (IPv6 address) records, not CNAME records.

This rule is in place to ensure the reliability and efficiency of email delivery because CNAME records introduce an additional level of indirection that can cause issues with the mail routing process.

Here's why MX records should not point to CNAME records:

  1. CNAMEs Can't Coexist with Other Resource Record Types: A CNAME record is a direct alias for another DNS record (usually an A or AAAA record) in the DNS hierarchy. It cannot coexist with other record types at the same domain name. MX records, on the other hand, must be created as separate resource records alongside other DNS records like A or AAAA records.
  2. Performance and Efficiency: MX records are critical for email delivery, and DNS servers need to quickly and efficiently look up these records to route emails. Using CNAMEs introduces additional DNS lookups and can lead to increased latency and potential issues with email routing.

To set up MX records properly for a domain, you should create A or AAAA records pointing to your mail servers' IP addresses. Then, you configure your MX records to reference these A or AAAA records. This ensures that email delivery can be efficiently routed to the correct mail servers.

If you need to change your email server configuration or move your email services to a different domain, it's a good practice to update the MX records directly to point to the new A or AAAA records associated with the mail servers, rather than relying on CNAMEs. This helps maintain the integrity and efficiency of your email infrastructure.

Conclusion

From understanding the basics of an MX record to learning how to query it, we've covered a wide range of topics related to DNS MX records. Hopefully this primer has given you the fundamentals and will put you on the right track as you continue exploring DNS and its benefits.

We recommend that you take some time now to familiarize yourself with backup MX records, since these can be just as important as regular ones when it comes to protecting email deliverability.

Lastly, keep in mind that although it's possible to point an MX record directly to a CNAME, this isn't usually a good idea for performance reasons. With this in mind, we wish you luck with all your MX mapping efforts!
Related articles
Improve your email deliverability now.
email deliverability