MX Record

What is an MX record?

Mail Exchange (MX) records are DNS records required to send an email to an address.

In simpler DNS terms, an MX record indicates which mail servers accept incoming mail for a domain and where emails sent to a domain should be routed. If the MX records do not point to the correct location, you will not be able to receive emails.

How does the MX record work?

The following will explain the operation of MX records through an example:

DNS records are found in zone files, which are nothing more than text files that gather all the records that refer to the area that the server in question is in charge of. When a client makes a request, the server that receives it obtains the information it needs from this file. Each type of record has a different function. Through the MX record, and according to the DNS, the client discovers in which domain the required email server is.

In most cases, several servers work with the same domain: in addition to the web server, which provides the web page, usually also an FTP server and one or more email servers, which are accessed through different subdomains, which can be required through the MX record. In general, the sending email server is the one that automatically takes care of this process.

Records fields and syntax:

DNS records are made up of different information associated with different fields. There are other details that can be added, in addition to pointing out the email server of a specific domain:

  • <name>: This is the first field and contains the domain name.
  • <ttl>: The lifetime tells what is the validity time of the information.
  • <class>: The type of network is determined in this field.
  • <type>: Here, you specify the type of DNS record (MX in this case).
  • <priority>: Indicates the email server’s priority; the lower the value, the higher the priority.
  • <rdata>: (Resource data) here is the name of the mail server.

In the record, all the fields are placed, on a single line, one after the other. You don’t have to use any special symbol to finish the registration; you just need a line break.

<name> <ttl> <class> <type> <priority> <rdata>

In practical terms, TTL and class fields are rarely displayed in records.

How to create an MX record?

The vast majority of web servers automatically create DNS records for clients, which by default are the host’s server. If you want to use another email provider apart from the hosting account, you must create an MX record.

However, it must be taken into account that when the MX records are changed, only the new mail that enters the updated email server is indicated. This means that emails that are already on an existing mail server will not be moved.

Understanding the structure of an MX record.

MX records use two main pieces of information when directing traffic: the domain name where the server is hosted and a priority number.

The priority number indicates the order in which a server will receive the emails and starts with the lowest priority available, starting from “0”. In the case that two servers share the same priority level available, either of the two will be chosen.

The other part, the domain name, is the particula mail server’s name where the mail is sent. Generally, it is something like “mail.DOMAIN.com.” There are hosting providers that have particular instructions for setting MX records and may require a “.” at the end of the server name, such as “mail.DOMAIN.com.”.

How do I configure MX records for Gmail?

The explanation is focused on creating MX records using Google’s already defaulted mail servers.

Google gives customers or users five different mail servers, giving each one a priority level in advance. These servers are:

ASPMX.L.GOOGLE.COM -> Priority 1

ALT1.ASPMX.L.GOOGLE.COM -> Priority 5

ALT2.ASPMX.L.GOOGLE.COM -> Priority 5

ALT3.ASPMX.L.GOOGLE.COM -> Priority 10

ALT4.ASPMX.L.GOOGLE.COM -> Priority 10

According to the priority settings established by default, the mail will be routed to the first available server, and that has the lowest priority level. Generally, this will be ASPMX.L.GOOGLE.COM since its priority level is 1.

But, if the first server is not available for some reason, the mail will be routed to the next server that is available at that moment. Since ALT1 and ALT2 have the same priority level, either of them will be sent at random.

MX records can be configured using the preferred control panel.

Changing an MX record with cPanel.

To make changes or configure MX records through cPanel, these are the steps:

First, you must log in to a cPanel account with the corresponding username and password.

Next, in the Mail part of the control panel, press the Modify the mail exchanger icon (MX entry).

Click on the option to change an MX entry.

The domain is chosen from the drop-down menu that appears.

If you are using Gmail, in the part called Add New Record, you will enter the server information indicated above.

The priority number is indicated for each record, always remembering that lower numbers give higher priority.

In the box that says Destination, enter the name/domain of the new mail server. If you use Gmail, you start with:

ASPMX.L.GOOGLE.COM

And this step is repeated for the other servers on the list.

When the MX record changes are complete, the Add New Record button can be pressed for the changes to be saved.

It should be noted that DNS propagation can take more than 48 hours to become effective.

Suppose want to delete an MX entry through cPanel. In that case, it can be done by clicking the Delete button next to the corresponding MX record and confirming the selection.