INSIGHTS
IT Careers & Learning

How MX Records Work in DNS: Complete Explanation for Beginners and Admins

In this article
  1. What an MX record contains
  2. How a sending mail server uses MX records
  3. Transient failures, queueing and permanent rejection
  4. No MX records, null MX and common mistakes
  5. TTL, authentication and message security
  6. A useful troubleshooting sequence

An MX (mail exchanger) record tells sending mail systems which hostnames accept email for a domain. It does not deliver the message itself, validate its contents or guarantee that a server will accept it. The sender still has to resolve the named host to an IP address, connect to a mail transfer agent over SMTP and receive an appropriate delivery response. Understanding that division of labor makes MX records easier to configure and troubleshoot.

What an MX record contains

In DNS, an MX record belongs to the recipient domain and supplies two important values: a preference number and the hostname of a mail exchanger. A smaller preference number means that the exchanger is tried before one with a larger number, subject to the sender’s retry behavior. That number is not an estimate of latency, capacity, security or server health. The exchanger hostname should resolve to the mail server’s address records; it is not itself an IP address or an instruction to use a particular mail client.

For example, the fictional domain example.com could publish:

example.com.       3600 IN MX 10 mail1.example.net.
example.com.       3600 IN MX 20 mail2.example.net.
mail1.example.net. 3600 IN A     192.0.2.10
mail2.example.net. 3600 IN A     192.0.2.20

Here mail1.example.net is preferred over mail2.example.net. The trailing dot identifies a fully qualified DNS name; without it, some DNS editing tools may append an unintended zone suffix. The addresses use documentation-only IP space, not production mail endpoints. If the listed exchanger also has an AAAA record, an SMTP client may use IPv6 according to its connection and address-selection behavior. In an actual zone, choose hostnames and addresses under your operational control and ensure that those systems really accept mail for the recipient domain.

How a sending mail server uses MX records

When a remote mail system needs to deliver a message to user@example.com, it identifies example.com as the recipient domain and obtains its MX records through DNS. It orders destinations by preference and resolves the selected mail exchanger hostname to A or AAAA addresses. It then attempts an SMTP connection, commonly to port 25 for server-to-server transport. The receiving server’s SMTP replies, not the MX record alone, establish whether the message was accepted or whether the sender should defer, retry or report a permanent failure.

If several MX records have the same preference, RFC 5321 requires the SMTP sender to randomize their order when no clear reason favors a particular exchanger. This can spread attempts across the group, but DNS MX preferences are not a load balancer with active health monitoring. They do not by themselves inspect server queues, route around saturated application processes or promise equal traffic distribution. A separate mail gateway, DNS-management service or operator policy may add those capabilities; do not attribute them to the MX record format.

A second exchanger with a larger preference can provide a fallback path when the preferred destination is unreachable. Whether a particular message is delivered immediately, queued for a retry or rejected depends on the failure type, SMTP response and sending-system policy. An MX record does not force uninterrupted handoff to a backup, and all listed mail servers must be configured to accept mail for the destination domain if they are expected to serve as backups.

Suppose mail for example.org lists 10 mx1.example.org and 20 mx2.example.org. A sender should normally prefer the exchange with the lower preference value, resolve that exchanger’s A or AAAA address and attempt SMTP delivery. If the first server is unavailable, the sending system can try the other exchanger according to retry policy and queue state. The mere presence of two entries does not make the second server an automatic replica: mailbox routing, user identities and anti-abuse policy must be coordinated by the mail operators.

The MX target should be a hostname with address records, not a naked IP address, and the SMTP standards advise against using a CNAME alias as the exchanger target. For example, the zone should not publish an MX pointing to a provider’s marketing domain merely because its website redirects. The service must publish the specific exchanger name expected by the provider. Where equal-preference exchangers exist, selection may distribute connections, but that is not the same as guaranteed load balancing or ordered message processing.

Transient failures, queueing and permanent rejection

Email delivery is store-and-forward rather than a guaranteed live connection between users. If a sender cannot reach a destination or receives a temporary SMTP response, it commonly queues the message and retries later. A permanent SMTP rejection normally ends that recipient delivery attempt and is reported to the sending side; retries are not an indefinite guarantee. Local retry schedules, queue lifetimes, error notifications and connection limits vary among mail transfer agents.

For investigation, distinguish three separate observations: the published DNS answer, the TCP connection to an exchanger and the SMTP conversation with that host. A valid MX answer can coexist with a blocked port 25, an exchanger that rejects the recipient, a TLS-policy mismatch or a mailbox that does not exist. Conversely, a visible destination failure may be transient while the sender still holds the message in its queue.

A 4xx SMTP reply means a temporary condition for which the sending system will generally queue and retry according to its configured schedule. A 5xx reply indicates a permanent rejection and usually leads to a non-delivery report without repeated attempts to the same rejected recipient. A TCP timeout is not an SMTP reply: diagnose reachability, firewall policy, DNS address resolution and the listening service before deciding whether the remote operator intentionally refused the message. The domain’s MX record cannot distinguish these outcomes.

A working exchange can still reject mail for policy reasons such as recipient nonexistence, rate limits, authentication requirements or reputation controls. Read the exact SMTP diagnostic and message headers where available. Avoid assuming that a low-priority backup MX can safely bypass the spam and recipient restrictions on the preferred server; otherwise attackers may intentionally deliver via the weakest route.

No MX records, null MX and common mistakes

Having no MX records is not the same as explicitly disabling inbound email. Under normal SMTP address-resolution rules, if a recipient domain has no MX, a sender can fall back to that domain’s A or AAAA address records. Administrators who do not want a domain to receive mail should not rely on leaving its MX records empty. RFC 7505 defines a null MX: one MX record with preference 0 and exchange ., signaling that the domain accepts no mail. A null MX should not be mixed with ordinary exchangers for the same domain.

Other operational mistakes include pointing an MX record directly at an IP address, using an exchanger hostname that does not resolve, publishing a backup that refuses the domain’s mail, assuming a lower number increases server performance, or changing the MX without preparing the new mail service. The DNS record type and SMTP infrastructure must agree. An MX target should resolve directly through suitable address records rather than being an alias that only leads through a CNAME chain; RFC 2181 explicitly prohibits CNAME aliases as MX targets.

Common configuration failures include pointing MX to a stale server name, forgetting the exchanger’s A/AAAA record, introducing a typo into a provider-issued target, leaving obsolete records during a mail migration, or configuring an inbound firewall to block TCP 25. Check the authoritative zone first, then compare how independent recursive resolvers see it. Changes propagate according to caching and TTLs, not instantly on every system.

TTL, authentication and message security

The numeric TTL on an MX record says how long a caching resolver may keep that DNS answer before refreshing it. It does not control how long a queued email is retained or how quickly a remote sender will retry. If a migration changes mail exchanger names or their IP addresses, plan the old and new endpoints, cache lifetimes and acceptance windows together. Resolver caching also explains why different senders can temporarily see different DNS answers during a planned cutover.

MX records describe inbound routing, whereas SPF, DKIM and DMARC address other parts of email authentication and policy. SPF authorizes specified sending infrastructure for an envelope domain; DKIM uses a cryptographic signature; DMARC relates authentication alignment and published handling policy to the visible From domain. None of these replaces an MX record, and an MX record is not proof that a message is authentic. Transport encryption and certificate validation are additional questions: STARTTLS, MTA-STS and DNS-based DANE policies depend on deployment and compatible peers. Do not assume that merely publishing an MX provides confidentiality.

DNS MX directs a sender to a server; SPF identifies authorized sending sources, DKIM supplies verifiable message signatures and DMARC describes domain alignment and receiver handling preferences. None of these mechanisms can be inferred from an MX preference number. TLS support is negotiated on the SMTP connection, while mechanisms such as MTA-STS or DANE can add transport policy when correctly deployed. DNSSEC can authenticate DNS answers where validation is in use; it does not encrypt the message or ensure mailbox delivery.

For changes that affect business mail, create a rollback record containing the previous MX entries, provider configuration, TTL and contact responsible for the receiving platform. Lowering a TTL in advance may help during a planned migration, but caches that saw a longer TTL before the change can still retain the older answer until it expires. Verify both incoming and outgoing mail independently because they rely on different configuration layers.

A useful troubleshooting sequence

Start with the affected recipient domain and inspect the live authoritative DNS data where practical. Confirm the MX preference order, the exact exchanger hostnames and their A/AAAA resolution. A typical resolver-side check might be:

dig MX example.com

dig A mail1.example.net
dig AAAA mail1.example.net

Next, test the supported SMTP connection path from the sending environment, inspect delivery queues and logs, and record the complete SMTP reply and timestamp. Compare that evidence with the published DNS records and the receiving server’s accepted domains, recipient policy, certificates and mail gateway configuration. If a change was recent, investigate DNS TTL and negative caching before calling a stale response a broken record. If the domain intentionally accepts no mail, verify that the single null-MX record is published correctly.

Bottom line: MX records select candidate SMTP receiving hosts by preference; the success of actual mail delivery depends on name resolution, network reachability, SMTP replies, recipient configuration and the sender’s retry policy. Keep those stages distinct when designing redundant mail routing or diagnosing a failed message.

Ask which sender, recipient and approximate timestamp were affected; check the authoritative domain, then query the MX RRset from independent resolvers. Follow each exchanger name to its A and AAAA records, examine connectivity to TCP 25 and inspect the sending queue and SMTP response. If only some senders fail, compare their DNS resolver view, IPv6 reachability and sender reputation. If messages arrive but users cannot see them, move the investigation from public MX records to mailbox routing, filtering and client synchronization.

Use safe test messages and avoid exposing message bodies or credentials in public troubleshooting reports. A useful incident record contains the domain name, current and previous DNS answers, command timestamps, the relevant mail-server log excerpts and the final verified outcome. An MX lookup that succeeds is only the first step; a successful SMTP acceptance or a delivered mailbox message is stronger evidence of service recovery.

Filed under IT Careers & Learning