MX record
An MX record or Mail exchanger record is a type of resource record in the Domain Name System (DNS) specifying how Internet e-mail should be routed. MX records point to the servers to send an e-mail to, and which ones it should be sent to first, by priority.
An MX record must contain a host name defined by an IN A record. IN CNAME aliases are not allowed to be used as MX record host names.
When an e-mail message is sent through the Internet, the sending mail transfer agent makes a DNS query requesting the MX record for the recipient's domain name, which is the portion of the e-mail address following the "@". This query returns a list of host names of mail exchange servers accepting incoming mail for that domain, together with a preference number. The sending agent then attempts to establish an SMTP connection to one of these servers, starting with the one with the smallest preference number, delivering the message to the first server with which a connection can be made. If no MX records were present, a second request is made for the A record of the domain instead.
The MX mechanism provides the ability to run multiple mail servers for a single domain and the order in which they should be tried, increasing the likelihood that mail may be delivered and providing the ability to distribute the processing of incoming mail across multiple physical servers. This ability to run multiple mail servers easily is proving very valuable for high-availability clusters of inexpensive mail gateways that can then process hundreds of messages per second -in aggregate- to quarantine or remove spam and/or viruses. Unfortunately, not all versions of all MTA pay attention to lower priority MX records - in other words: if the highest priority MX server fails, the MTA doesn't bother to address the backup server.
The MX mechanism does not grant the ability to provide mail service on alternative ports, nor does it provide the ability to distribute mail delivery across a set of equal-priority mail servers by assigning a weighting value to each one. As of 2004, some MTAs, most notably exim, now support the use of SRV records for publishing the IP addresses, ports, priority, and weights of mail servers.
In order to check the MX record for a domain using Windows, first open a command prompt window (click Start->Run, then type cmd). A command prompt window will appear. Type nslookup and hit enter. Then type "server <DNS>" (such as ns1.serverdomain.com) and hit enter. Then type "set type=mx" without quotes and hit enter. Then type the domain name such as wikipedia.org and hit enter. The mx record will then be displayed.
MX priority
A primary point of confusion is how the priority system works for MX selection. The relative priority of an MX server is determined by the preference number present in the DNS MX record. When a remote client (typically another mail server) does an MX lookup for the domain name, it gets a list of servers and their preference numbers. The MX record with the smallest preference number has the highest priority and is the first server to be tried. The remote client will go up the list of servers until it successfully delivers the message or gets permanently rejected due to an unreachable server or if the mail account does not exist on that server. If there is more than one entry with the same preference number, all of those must be tried before moving on to lower-priority entries.
A favorite technique of spammers is to connect to the lowest priority MXs for a domain (those with the largest numerical value) in an attempt to avoid any anti-spam filters that may be running on the primary (highest priority) MX. Computer viruses have also been known to employ this technique in an effort to avoid anti-viral software.
See also
- LOC record
- SRV record
- Email hub: MX based load-balancing and simple failover.
References
- RFC 974 (1986), Mail Routing and the Domain System (obsolete)
- RFC 2821 (2001), Simple Mail Transfer Protocol
External links
- MX Tool Box - "MX lookup and blacklist lookup."
- "Moving a message closer to a remote recipient", part of Daniel J. Bernstein's guide to Internet mail infrastructure
- Tools to find the mail servers used by an e-mail address: