A DNS ‘mail exchange’ (MX) record directs email to a mail server. The MX record indicates how email messages should be routed in accordance with the Simple Mail Transfer Protocol (SMTP, the standard protocol for all email). Like CNAME records, an MX record must always point to another domain.
A DNS MX (Mail Exchange) record is a type of DNS (Domain Name System) record that specifies the mail servers responsible for receiving email messages on behalf of a domain. MX records play a crucial role in the email delivery process by directing email traffic to the correct mail servers.
Each MX record contains two main pieces of information:
- Mail Server Priority (Preference): An integer value indicating the priority or preference of the mail server. Lower values indicate higher priority. When multiple MX records exist for a domain, email servers will attempt to deliver mail to the server with the lowest priority first. If that server is unavailable, the next lowest priority server is tried, and so on.
- Mail Server Domain Name: The domain name (fully qualified domain name or FQDN) of the mail server that will handle email delivery for the domain. This is the actual destination where email messages should be sent.
Here is an example of an MX record:
Priority: 10 Mail Server: mail.example.com
In this example, the mail server at “mail.example.com” has a priority of 10. If there are multiple MX records for the same domain, the email server will attempt to deliver email to the server with the lowest priority value first.
Example of an MX record:
The ‘priority’ numbers before the domains for these MX records indicate preference; the lower ‘priority’ value is preferred. The server will always try mailhost1 first because 10 is lower than 20. In the result of a message send failure, the server will default to mailhost2.
The email service could also configure this MX record so that both servers have equal priority and receive an equal amount of mail:
This configuration enables the email provider to equally balance the load between the two servers.
It’s important to note that MX records are used primarily for inbound email delivery. Outbound email servers typically do not rely on MX records; instead, they use the destination email address’s domain to perform a DNS query and find the appropriate MX records for the recipient domain.
Add an MX record
MX records (or Mail eXchanger record) tell email services connected to your domain, such as Microsoft 365, where and how to deliver emails. If your domain is using POWERHOSTER.COM nameservers and it’s connected to one of our email services, we’ll automatically add the required MX records for you.
- Sign in to your POWERHOSTER.COM Domain Portfolio. (Need help logging in? Find your username or password.)
- Select an individual domain to access the Domain Settings page.
- Select DNS to view your DNS records.
- Select Add New Record and then select MX from the Type menu.
- Enter the details for your new MX record.
- Name: The hostname or prefix of the record, without the domain name. Enter @ to put the record on your root domain, or enter a prefix such as mail to deliver mail to an email address like [email protected].
- Priority: The priority determines which record to contact first when multiple MX records exist on the domain. A lower number means more preferred, and the record with the lowest priority will be used first.
- Value: The domain of the mail server, such as smtp.secureserver.net.
- TTL (Time to Live): The amount of time the server should cache information before refreshing. The default setting is 1 hour.
- (Optional) Select Add More Records to add multiple DNS records at the same time. If you change your mind, select Delete to remove any records that haven’t been saved yet.
- Select Save to add your new record. If you added multiple records at the same time, select Save All Records.
What is The Process of Querying an MX Record?
Message transfer agent (MTA) software is responsible for querying MX records. When a user sends an email, the MTA sends a DNS query to identify the mail servers for the email recipients. The MTA establishes an SMTP connection with those mail servers, starting with the prioritized domains (in the first example above, mailhost1).
What is a Backup MX Record?
A backup MX record is just an MX record for a mail server with a higher ‘priority’ value (which means a lower priority), so that under normal circumstances mail will go to the more prioritized servers. In the first example above, mailhost2 would be the ‘backup’ server because email traffic will be handled by mailhost1 as long as it is up and running.
Can MX Records Point to a CNAME?
No, according to the DNS specifications (RFC 2181), MX (Mail Exchange) records cannot directly point to a CNAME (Canonical Name) record. MX records must point to domain names directly, and they cannot point to other domain aliases or CNAME records.
The reason for this restriction is to ensure the reliability and efficiency of email delivery. When an email server needs to deliver an email, it performs a DNS lookup to find the MX records for the recipient’s domain. The MX records specify the mail servers that are responsible for receiving emails for that domain. If an MX record pointed to a CNAME, it could introduce additional DNS lookups and increase complexity in the email delivery process.
To correctly set up email services for a domain, you should create MX records that directly point to the hostnames (domain names) of the mail servers responsible for receiving emails for that domain. These mail servers are typically specified by their A (IPv4 address) or AAAA (IPv6 address) records.
A CNAME record is used for referencing a domain’s alias instead of its actual name. CNAME records typically point to an A record (in IPv4) or AAAA record (in IPv6) for that domain. However, MX records have to point directly to a server’s A record or AAAA record. Pointing to a CNAME is forbidden by the RFC documents that define how MX records function.