The What, the Why and the How of MX Lookup
August 3, 2019 | by lily
Mail exchange or MX lookup is the listing of MX records for domains in priority order. MX lookup is done directly against the authoritative name server of a domain, meaning any change in the MX record will be visible instantly. These MX records specify how emails should be routed through the Simple Mail Transfer Protocol. An MX record is basically a resource record. A resource records is the basic information element of the Domain Name System or DNS. A resource record is distinguished by a type identification (NX, A, MX, etc.) and a DNS class (CHAOS, Internet, etc.). A resource record has a validity period (or a time-to-live) assigned to it. This indicates when the information contained therein must be refreshed by an authoritative name server. A resource record is organized within a DNS based on its name field, which is a FQDN or fully qualified domain name of a node in the DNS tree. In MX records, this specifies the domain name of the email address of the mail recipient (this is the portion after the ‘@’ symbol delimiting the account name of the mail recipient). You can do an MX lookup in a website dedicated to this. All you need to do is to connect to a mail server, to verify the reverse DNS record, to perform a simple Open Relay check, and to measure the performance of the response time. You can check each MX record against different DNS based blacklists (RBLs or DNSBLs). Internet email systems depend on DNS MX records for the transmission of emails between domains (or zones). Each domain can have several MX records and each of these will specify a different host that has a priority level. Hosts that have the lower priority levels are the ones that are contacted first during emails arrival. DNS can be taken to be a large phonebook where you can find all IP addresses. Whenever you search for a domain name, the computer first contacts a name server to do ‘DSN lookup’ of the IP address corresponding to the domain name in a process. This is called Resolving DNS. DSN is however different from phonebooks in that it is not a centralized server – it is designed as a distributed database made up of independent name servers. There are several reasons why you need to do MX lookup. MX lookup is advantageous in that you are able to run multiple mail servers for 1 domain. This allows you to specify the order in which the different mail servers should be tried. This is particularly important for high-availability clusters of inexpensive mail gateways, which are able to process hundreds of messages every second to remove or quarantine viruses and/or spam. MX lookup will help you distribute delivery across mail servers that are equal-priority. The SMTP protocol characteristic of MX records establishes a store-and-forward network, meaning if the mail servers of a domain are all offline, sending servers queue messages that are destined for that domain to retry later. So, how does the MX lookup work? Whenever an email message is sent, the sending mail transfer agent will query the DNS for MX records of the domain name of each recipient. This query generates a list of host names of different mail exchange servers that are accepting incoming mail for that domain as well as their preferences. The sending agent will then attempt to establish an SMTP connection to one of the servers listed in the MX lookup process. This usually starts with the server that has the smallest preference number.