Management: Email Exchangers

What MX Records Do
As a part of the DNS function provided by bind, the program that actually provides the directory services, DNS specifies the servers (hosts) that manage your email. These are defined in your DNS database as MX, mail exchanger, records. This is true weather or not the DNS is static or dynamic.

It is important that the MX records be configured correctly. At best, if the records are not correctly configurred, no mail will be delivered. At worst you will end up with a mail loop and consume large server resources.

Here is the simplest entry you need to deliver email to anyone@mydomain.com. Of course, the server mail.mydomain.com must be running an SMTP server such as sendmail or postfix.

Table 1

mydomain.com. 86400 IN MX 10 mail.mydomain.com.

You will need an MX record in your DNS database unless you are sending mail directly to a host capable of receiving it. For example if all mail is being addressed directly to mail.mydomain.com then you don't really need an MX entry in your DNS database.

Table 2

yourdomain.com. 86400 IN MX 10 mail.yourdomain.com.
yourdomain.com. 86400 IN MX 20 backup.yourdomain.com.
yourdomain.com. 86400 IN MX 50 smtp.isp.com.

In Table 2 you can see three MX records. This is because it is conceivable that your primary mail server become unavailable (non functional). To avoid having email bounce, we have setup a backup mail server that will receive email in the case that mail.yourdomain.com is not accepting mail. This is the backup.yourdomain.com entry. The 5th column defines the priority order in which each mail server will be tried.

The final entry, mx.mailhop.com, provides a final resource for mail if the primary and backup mail server cannot accept the mail. Consequently, it has the lowest priority, highest priority number.

It has been noted that some versions of MS Exchange Server don't work correctly without the appropriate MX records in the DNS database.

TTL & Caching
You will note that there is a large number in the second column. This is the time to live value and defines how long any caching DNS servers will 'remember' where to send email for your domain. This can sometimes result in delays if your primary mail server stops accepting mail but, in the normal course of events, makes mail distribution a lot more efficient.

Creating MX Records in Dynamic/Static DNS
We, like most hosting services, provide easy to edit MX records to simplify the configuration of your mail server. These are available to you if you are using our DNS service.

As a further example and note, you cannot use CNAME records to define your mail exchangers (MX records), you must use IN in the 3rd column and provide the host IP address or host name. This example is configured where the web server provides the mail services in addition to the web services.

www.mydomain.com. 43200 A IN 127.0.0.10
mydomain.com. 43200 IN MX 10 www.mydomain.com.

Here is an example where the web server is the primary mail server but there is a backup server:

www.mydomain.com. 43200 A IN 127.0.0.10
mydomain.com. 43200 IN MX 10 www.mydomain.com.
mydomain.com. 43200 IN MX 20 mail.mydomain.com.

This is an example where your hosting service or DNS service provider actually provides your email services:

mydomain.com. 43200 IN MX 10 smtp1.isp.com.

MX Record Configuration Summary

  • Remember that you must not use CNAME records to define hosts but provide a host name defined by an A record
  • Don't create MX records that point to and IP address
  • If you are using multiple MX records, the interval between the priority numbers is not significant but the order is.
  • If you only have a single MX record and single mail server, the value of the priority value used is not significant.

There are many places on the Internet where you can find additional information on configuring DNS records for mail services. Please be aware that configuring and maintaining a mail server is not for the faint of heart.