What Is an MX Record in DNS?

Though you likely use email regularly for work or personal communication, you may not know how these digital letters make their way to the right inbox. One of the key parts of the email process is the MX record. A mail exchange record routes emails to specific mail servers, ensuring messages are delivered. In this article, learn what DNS MX records are, how they work, how to set them up, and why they matter.

What is an MX record?

A DNS MX record, short for mail exchange record, is a resource record within the domain name system (DNS) that directs email to a particular mail server. This mail server accepts email messages on behalf of a domain's recipients or users.

Essentially, a mail exchange record is the road sign for your emails, pointing them in the direction of your domain's mail server. These records exist in the broader domain name system, as mentioned above. DNS is the Internet's equivalent of a phone book, translating human-readable domain names into machine-readable IP addresses needed for routing data.

MX records are an important type of DNS record.

Mail exchange records are a type of DNS record, which are sets of instructions within the DNS that guide Internet traffic. Each record type has a different purpose; the MX record, in particular, concerns email communication. Mail exchange records are typically held within a DNS zone file.

An MX record is made up of two parts, both of which are essential for delivering messages to your mailbox: the priority and the target.

  • Priority is a number that dictates the order in which email servers should attempt to deliver email. Lower numbers indicate higher priority.
  • Target is the domain name of the email server where the email needs to be delivered.

When you hit 'send' on an email, your server checks the DNS for the recipient's MX records. It then sends the email to the recipient's email server as dictated by the mail exchange record.

What does an MX record do?

An mail exchange record tells the Internet how to route emails for your domain. It points to your domain's mail servers. When someone sends an email to your domain, the sender's email service will look up your MX records to see which servers handle email for your domain. Then, it passes the email onto those servers, which deliver it to your inbox.

Without mail exchange records, no one would know how to get emails to you. Most domain registrars make it easy to set up MX records when you buy a domain. Enter the names of your mail servers (like mail.yourdomain.com) and the registrar creates the mail exchange records for you.

How MX records work

The MX record indicates how your email messages should be routed in accordance with the SMTP (Simple Mail Transfer Protocol), a protocol used for sending emails over the Internet.

To understand how MX records work, you must know the role of DNS servers and message transfer agents (MTAs) in the email delivery process.

The process follows these steps:

  1. A sender composes an email and hits Send.
  2. The email client, like Microsoft Outlook or Gmail, forwards the message to an email server.
  3. The sender's MTA sends a DNS query to identify the mail exchange record associated with the recipient's domain.
  4. The sender's MTA establishes an SMTP connection with the destination mail server.
  5. The email arrives in the recipient's inbox, making it a successful delivery.

Many domains have multiple mail exchange records that point to different mail servers. This offers a secure backup in case one goes down. The numbers next to each mail server in your MX records indicates priority.

The record with the lowest priority number is used first; if that server is unavailable, the secondary record with the next lowest priority number is used, and so on.

Most email hosting providers give you the mail exchange records to use for your domain when you subscribe to their email service. The user then just needs to add those mail exchange records to their domain's DNS zone file to start receiving email.

How to set up MX records for your domain

Setting up MX records for your domain is a task typically reserved for systems administrators or those who manage a domain. If you're an administrator, here is a simplified step-by-step guide for setting up your domain's MX records.

  1. Log into your DNS provider. This is the service where you purchase and manage your domain name. It could be a domain registrar like GoDaddy, a cloud services provider like Amazon AWS, or a dedicated DNS provider like Cloudflare.
  2. Locate the DNS management section. Look for an option that says 'DNS settings' or something similar. Here, you can then control settings like MX records, AAA records, and CNAMEs.
  3. Add an MX record. Look for an option to add a new record and select 'MX' from the dropdown list.
  4. Add the server address in the 'Value' or 'Points to' field. This address should be provided by your email hosting service.
  5. Set the priority for this server. Be mindful that lower numbers indicate a higher priority. The priority number controls the order in which mail servers are contacted.
  6. Save your changes. Save the changes to your mail exchange records to complete the process.

With the records added, your domain will now route incoming emails to the designated mail servers. However, note that it can take 24 to 48 hours for the changes to fully update across the Internet.

Once propagation has completed, you can start receiving emails for your domain on the mail servers you specified. Be sure to test that the new mail exchange records are working properly by sending some emails to accounts on your domain.

How to choose the right MX record priority

When configuring MX records, the priority value is important. The lower the priority number, the higher the preference.

For most simple email configurations, you only need one mail exchange record with a priority of 10. However, to set up backup email servers in case your primary suffers an outage, add multiple mail exchange records with different priorities.

The email server with the lowest priority number comes first. In cases of unavailability, the system tries the email server with the next lowest priority. This ensures your email service has fallback options in case of an outage with a server.

What is a backup MX record?

A backup mail exchange record is a DNS record for a mail server with a higher priority value. Its main benefit is to provide reduncancy for your domain's email routing.

if your primary MX record misbehaves for some reason, then the backup MX will take over and continue directing incoming emails to the appropriate mail servers.

Without a backup MX record, your email could stop working entirely should an issue occur with your primary MX server. The goal of the backup MX is to ensure maximum uptime and reliability for your domain's email. It should, however, point to a mail server aside from your primary MX.

Some DNS providers allow you to specify a backup MX priority. Setting a backup mail exchange record for your domain is an easy way to add an extra layer of protection for your email service.

For maximum reliability, you'll want to have a good monitoring system in place to alert you when both mail exchange records become unavailable.

When do you need an MX record?

You need an MX record if you want to:

  • Use a custom email address with your domain
  • Have a branded email for your business or organization
  • Accept email for a website contact form
  • Host email accounts for multiple users

Essentially, if you want a professional business email, a contact form, or multiple email accounts with your domain, an MX record is essential because it enables you to take full advantage of email services and your domain.

What happens if I change my MX record?

If you change your mail exchange record, it can take 24 to 48 hours for the changes to fully propagate across the Internet's DNS system. During this time, some email providers and servers may still be directing mail to your old mail exchange records.

Once the changes are complete, incoming email will be delivered to the new destination specified in your updated mail exchange records. This means if you point your mail exchange records to a new email service provider, like Gmail, newly sent emails will start arriving in the new service.

The same applies if you update MX records to point to different servers at your current email provider. The changes may not happen instantly, but in no time, email flow will shift based on the updated information in your domain's records.

Example of a mail exchange record

An MX record tells email servers where to deliver email for a domain. For example, if you own the domain "example.com," you would create an MX record to specify which mail server should handle email for that domain.

The MX record would look something like this:

example.com IN MX 10 mail.example.com

Broken down, it means the following:

  • example.com - The record is for the example.com domain.
  • IN MX - The record is an MX record.
  • 10 - The priority number is 10.
  • mail.example.com - Mail for example.com should be delivered to the example.com mail server.

An MX record routes email to the proper server and acts as an important part of email deliverability for any domain.

How do you troubleshoot MX records?

Troubleshooting MX records requires understanding the potential issues that are likely to occur. Common issues include:

  • Missing MX records
  • Misconfigured records
  • No backup server
  • Servers that don't respond
  • Improper priority values

To diagnose these issues, you can use an MX record lookup to check MX records for problems. Once you've identified the problems with the MX lookup tool, you can correct the record configuration in your DNS settings accordingly.

If a server still isn't responding, you may need to contact your email hosting provider.

Frequently asked questions

What is the priority in mail exchange records?

Priority in MX records is a number assigned to each mail exchange record that dictates the order in which servers should be attempted for email delivery. Lower numbers indicate higher priority.

Can multiple MX records exist for a domain?

Yes. Multiple MX records exist for a single domain. This is common in domains with large volumes of email traffic.

Can mail exchange records be changed?

In short, yes. You can change records if the need arises. Changes might occur when switching email hosts or when adding backup mail servers.

How do I know if my MX record is working correctly?

If emails are being received at the intended destination without delay or bounce-back messages, your mail exchange records are configured correctly.

Are MX records different from other DNS records?

Yes, mail exchange records are distinct from other types of DNS records. While they all facilitate routing Internet traffic, mail exchange records specifically guide the routing of email.

Other types of records, such as A, AAAA, or CNAME records, serve different functions, like linking domain names to IP addresses.