The Domain Name System (DNS) is a complicated solution that links domain names to their IP addresses. The purpose is to make it easier for people. We remember names that we can easily write and keep in our memory and get to sites, that we need to know their location on the network – their IP addresses.
The DNS works with text commands that computers understand. These commands are called DNS records, and they are saved on DNS nameservers. In our case, we will explore the MX record and what other types of records you will need with it for a functional mail server.
What is the Mail Exchanger record (MX record)?
The MX record is a simple DNS record that holds the instruction for the sending email servers that tells them the name of the responsible server for accepting emails on behalf of the domain name.
For example, if we have a domain name called example.com, we need to add an MX record that links this domain name to the name of the host (mail server for receiving emails) for accepting emails like mail.example.com.
Then the senders need to get the A record or AAAA records of the mail.example.com, and they will know not only the name of the host but the IP address too.
In the zone of mail.example.com, you can’t have CNAME records, and you need to have A or AAAA records. CNAME doesn’t allow other records in the zone.
You can have multiple MX records that point to multiple hosts, like mail1.example.com, mail2.example.com, and so on, for redundancy.
The MX records have another important parameter, and it is the priority. It indicates the order of importance of accepting mail servers. A lower number means higher priority. You can have different hosts with the same priority or with different priorities. The senders will always try to send to the host with the lower priority first.
A common approach is to have one incoming mail server with a very high priority serving as a backup. Normally, it won’t receive emails, but in case all the rest with lower priority fail, it can receive the messages.
What happens if you don’t have MX records?
The MX records will point to the mail servers for receiving emails for your domain. If you are missing this pointer, the senders won’t know where to send the messages. It is like having a house without a mailbox. They either fail, or they will try to send the emails directly to the domain name, like example.com, and to its IP address (IPv4 or IPv6) with priority 0. The delivery is not guaranteed.
What other DNS records you need for your mail server?
When we talk about DNS, you will need the following DNS records so you can send and receive emails with lower bouncing rate and fewer missed emails for your inbox:
MX record – points which are the incoming mail servers (their hostnames).
A or AAAA records – you need A or AAAA records for your domain name and also for the hosts that you have. They point names to IP addresses.
SPF record – another text record. This one will show which servers can send emails on behalf of your domain.
DKIM record – To encrypt the sent messages and proof that the messages were not forged on the way.
DMARC record – To verify the SPF and the DKIM and to provide feedback to the domain owner or manager.
PTR record – the pointer record is opposite to the A or AAAA records and links IP address to a domain name. It is used for verification purposes as proof that the IP address is corresponding to the domain.