Tuesday, May 21, 2024
HomeUNIX softwareBIND and DNSDNS/BIND Resource Record: Routing Mail with MX Records

DNS/BIND Resource Record: Routing Mail with MX Records

Proper DNS configuration with MX records is a requirement for routing email for a domain.

When an email is sent to a domain, the sending mail server performs a DNS query to find the MX records associated with the recipient’s domain. MX records have a preference value (numeric from 0-65535). The sending mail server tries the lowest preference value MX record first. If that server is not reachable, the MX record with the second lowest preference is tried. This continues until a connection is made or no MX records remain.

The following three mail servers listed in order of preference are to be configured in the code below:

mx1.tech-recipes.com. (primary mail relayer)
mx2.tech-recipes.com. (secondary mail relayer)
mxbackup.offsite.domain. (tertiary mail relayer, offsite)

tech-recipes.com. mx 10 mx1.tech-recipes.com.
tech-recipes.com. mx 20 mx2.tech-recipes.com.
tech-recipes.com. mx 30 mxbackup.offsite.domain.

The names of the servers in MX records must be fully qualified hostnames, not IP addresses. If two or more MX records exist with the same preference, many mail transfer agents will use the two servers in a round-robin fashion, which could help balance the load between the servers.

The offsite mail relayer is a wise idea because it allows mails to be queued on that server while the network connection to the primary servers is down.

Misconfigurations in DNS can cause problems that affect many other systems and may not present as DNS issues. Problems with MX records can cause serious email delivery issues. A common problem with MX records (and DNS records in general) is leaving off the trailing period after the fully qualified domain name of the mail servers.

Quinn McHenry
Quinn McHenry
Quinn was one of the original co-founders of Tech-Recipes. He is currently crafting iOS applications as a senior developer at Small Planet Digital in Brooklyn, New York.


Please enter your comment!
Please enter your name here

Most Popular


Recent Comments

error: Content is protected !!