Girish Mahajan (Editor)

MX record

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit

A mail exchanger record (MX record) is a type of resource record in the Domain Name System that specifies a mail server responsible for accepting email messages on behalf of a recipient's domain, and a preference value used to prioritize mail delivery if multiple mail servers are available. The set of MX records of a domain name specifies how email should be routed with the Simple Mail Transfer Protocol (SMTP).

Contents

Overview

Resource records are the basic information element of the Domain Name System (DNS). They are distinguished by a type identification (A, MX, NS, etc.) and a DNS class (Internet, CHAOS, etc.). The records have a validity period (time-to-live) assigned to them, indicating when the information they hold must be refreshed from an authoritative name server. Resource records are organized within the DNS based on their name field, which is a fully qualified domain name (FQDN) of a node in the DNS tree. In the case of an MX record, this specifies the domain name of a mail recipient's email address, i.e. the portion after the @ symbol that delimits the recipient's account name.

The characteristic payload information of an MX record is the fully qualified domain name of a mail host and a preference value. The host name must map directly to one or more address record (A, or AAAA) in the DNS, and must not point to any CNAME records.

When an e-mail message is sent through the Internet, the sending mail transfer agent (MTA) queries the Domain Name System for MX records of each recipient's domain name. This query returns a list of host names of mail exchange servers accepting incoming mail for that domain and their preferences. The sending agent then attempts to establish an SMTP connection.

The MX mechanism provides the ability to run multiple mail servers for a single domain, and allows administrators to specify an order in which they should be tried. This ability to run multiple mail servers proves very valuable for high-availability clusters of inexpensive mail gateways, which can then process hundreds of messages per second in aggregate to quarantine or remove spam and/or viruses.

The MX mechanism does not grant the ability to provide mail service on alternative port numbers, nor does it provide the ability to distribute mail delivery across a set of unequal-priority mail servers by assigning a weighting value to each one. MX can be used to distribute delivery across equal-priority mail servers.

History of fallback to address record

RFC 821 was published in 1982. It makes only passing references to DNS, because at the time the transition from HOSTS.TXT to the DNS had not yet started. RFC 883, the first description of the DNS, was published over a year later in late 1983. It described the experimental and little used MD and MF records. According to RFC 897 and RFC 921, the transition to DNS started in 1983, but HOSTS.TXT was not scheduled to be phased out until the end of 1985 and was not totally phased out until the late 1990s.

In January 1986, RFC 973 and RFC 974 deprecated the MD and MF records, replaced them with MX, and defined the MX lookup with fallback to A. RFC 974 recommends that clients do a WKS lookup on each MX host to see if it actually supports SMTP and discard the MX entry if not. However, RFC 1123 changed this to say that WKS should not be checked.

This means that SMTP had been in use for at least a year using HOSTS.TXT, and then another couple of years using A, MD, and MF, before MX came along. MD and MF were hard to use, so most people just used the A record. Under the circumstances, MX without fallback to A would not have worked because of the substantial installed base of mail servers using A records. The early use of MX was to identify gateways to other networks, but it did not come into wide use until the DNS was well established in the early 1990s.

RFC 5321 sec. 5 states:

  • SMTP clients must look up an MX record;
  • if (and only if) no MX record for the domain is present, treat the domain as if it had an MX record with the given domain as the target hostname and a preference value of 0
  • perform A or AAAA lookups as required to determine the IP address of the target hostname
  • Standards documents

  • RFC 1035 (1987), Domain Names - Implementation and Specification
  • RFC 1912 (1996), Common DNS Operational and Configuration Errors
  • RFC 5321 (2008), Simple Mail Transfer Protocol
  • RFC 7505 (2015), A "Null MX" No Service Resource Record for Domains That Accept No Mail
  • Obsoletes:

  • RFC 2821 (2001), Simple Mail Transfer Protocol (obsoleted by RFC-5321)
  • RFC 974 (1986), Mail Routing and the Domain System (obsoleted by RFC-5321)
  • References

    MX record Wikipedia