This is the fourth installment In the of a ten-part series outlining the ten most common Domain Name System (DNS) Records. In this article I will examine Mail Exchange Records, or MX Records. Find links below to the previous articles:
- In the third article I examined CNAME Record
- In the second article I discussed the AAAA Record
- In the first article I discussed the A Record
MX Records Overview
MX Records specifies the mail server responsible for accepting email messages on behalf of a domain name. If your MX Records are not configured or configured improperly you will not be able to send and/or receive email. Setting up MX records can be simple or complex, depending on who manages your website’s DNS and which flavor of email you choose.
I’m going to define three types of mail platforms:
- Proprietary Systems like Microsoft Exchange and IBM Notes.
- Webmail such as gmail, outlook.com, or yahoo mail. This tier includes the free accounts as well as paid email, like Gsuite.
- Free – it is possible to setup email to your personal or business domain without paying for it, but I would not personally recommend this option unless you have countless hours to setup and maintain it.
Some platforms provide robust services, like Microsoft Office 365 or Gsuite. There are also less expensive options like Zoho Mail and Fatcow. Finally there are free options if you want to spend your time setting up email (and then configuring it until you finally get it right, not to mention maintaining it). I’m not going to link anything here because, quite frankly, I’ve yet to find one that has all the information you need to configure it to work properly.
The platform you choose to setup email hosting will likely determine how easy or difficult it will be configuring your MX Records. I have had email on all of these tiers, and each have their benefit – you will either be spending your time or your money, choose wisely.
MX Record Setup
Below is GoDaddy’s template for adding an MX Record – your DNS provider may have a slightly different layout, but the fields will be the same or similar.
- Type – this is the name of the DNS Record. You can almost always choose the type of DNS Record you want to add from a dropdown.
- Host – this is typically your domain. Many providers allow or require you to type in @ to refer to “yourdomain.com”
- Points to – this is the name of your mail server. The name of your mail server will vary depending on your email platform. In its simplest form, it’s something like mail.yourdomain.com.
- Priority – determines the order (which mail server) that your mail will be attempted to be delivered. The mail server with the lowest priority will first be attempted to have the email delivered. If there is only one mail server available, this priority value is not important. Enter a value between 0 and 65535, since the value is a 16-bit field in DNS. If you try to use a number greater than 65535 you run the risk of unexpected results. Here’s a nice article that discusses Transaction IDs in DNS and the 16-bit field impact on DNS; search for header Randomization for DNS Transaction Identifier.
- TTL (Time To Live) – this is how long this record would live on the server (with current settings) should you ever update it or change it. I wrote extensively on TTL in this article.
Your DNS Provider should have links to help articles to help you setup your MX Records based upon the mail provider you choose. Certain DNS Providers partner with specific platforms and have some automation in place that will do the setup for you. For example, if your DNS provider is GoDaddy and you purchase Office 365 through them, there’s a fully-automated and seamless setup of email for your domain. Another DNS provider, DirectNic, is a much more affordable option which encourages you to use open source tooling for your email client and setup for that client is a breeze, though manual. The lists and combinations are nearly endless – and when all else fails, use Google with good intentions to solve your issues.
MX Records – Digging Deeper
Transport of Email is governed under RFC 5321, which defines Simple Mail Transfer Protocol (SMTP). MX Records must be used conjunction with A Records. The A record will point to the mail server’s IP Address. When another mail server wants to communicate with your mail server, it will look for an MX record. The MX record must point to the A record which points to the mail server’s IP address.
The domain servers store information as a series of resource records (RRs), each of which contains a particular piece of information about a given domain name (which is usually, but not always, a host). The simplest way to think of a RR is as a typed air of datum, a domain name matched with relevant data, and stored with some additional type information to help systems determine when the RR is relevant. For the purposes of message routing, the system stores RRs known as MX RRs. Each MX matches a domain name with two pieces of data, a preference value (an unsigned 16-bit integer), and the name of a host. The preference number is used to indicate in what order the mailer should attempt deliver to the MX hosts, with the lowest numbered MX being the one to try first. Multiple MXs with the same preference are permitted and have the same priority.