Wesloo
All topicsTopics

Email

What Are MX Records and How Do They Work?

Short answer

MX records are DNS entries that name the mail servers responsible for receiving email for a domain. They include a priority number so sending servers can choose the preferred destination and fall back to alternatives if needed.

Key points

  • An MX record points a domain to a mail server hostname, not an IP address.
  • Lower preference numbers mean higher priority.
  • Multiple MX records can provide backup delivery paths.
  • Changes are read from the authoritative name server.
  • MX targets should not be CNAME aliases.
What are MX records? An MX record is a DNS resource record that tells sending mail servers which host is responsible for accepting email for a domain. It does not carry the message itself; it only publishes the destination that SMTP clients should try. A domain can publish one MX record or several, and each record pairs a priority number with a hostname.

What are MX records in DNS?

An MX record lives in the Domain Name System and names the mail server that accepts messages for a domain. When someone sends mail to an address at that domain, the sending server asks DNS for the MX records before it opens an SMTP connection. The answer is a hostname, not an IP address, so the sender then resolves that hostname to an address. This separation lets a domain move mail hosting without changing every email address.

How an MX lookup works

DNS resolution for mail starts with the domain in the recipient address. The sending mail transfer agent queries the domain's authoritative name server for MX records. If records exist, the agent uses them in priority order. If no MX record exists, mail software may fall back to the domain's A or AAAA record in some cases, but publishing MX records is the clear and reliable method. Because the lookup goes to the authoritative server, a change to an MX record should show up instantly.

Example of a simple MX setup

Imagine a domain with one MX record: mail.example.com at priority 50. A sender looking up that domain receives only that hostname and attempts delivery there. The number 50 is arbitrary; any integer permitted by the SMTP specification would work. If the domain later adds a second record, such as backup.example.com at priority 100, senders still prefer mail.example.com and use the backup only when the first path fails. This keeps the common case fast while preserving a fallback.

Priority, backup servers, and retries

Each MX record has a preference value. RFC 5321 treats the lowest number as the most preferred destination, so a record with priority 10 is tried before one with priority 20. The number is only a ranking; 10 and 20 work the same as 1 and 2 if no other records sit between them. When two records share the same preference, they have the same priority and the sender can choose between them, which helps spread load. If the preferred server cannot be reached or rejects the attempt in a way that allows retry, the sender tries the next record. The SMTP specification is not fully precise about which failures must trigger that fallback, so operators should not rely on a backup server to catch every kind of error.

Load balancing and reliable delivery

Multiple MX records, multihoming, or both can turn one domain's mail routing into a list of alternative delivery addresses. For reliable delivery, the sending client must try, and retry, every relevant address in order until one attempt succeeds. This is why a domain with two MX records at the same priority can distribute inbound connections, while a domain with a low-priority record keeps a backup ready. The benefit is availability, not guaranteed delivery: a backup server still needs correct users, storage, and filtering rules.

Record format and common limits

FieldMeaningExample
NameDomain that receives mailexample.com
TypeRecord typeMX
PriorityPreference value; lower is preferred10
TargetHostname of the receiving mail servermail.example.com
TTLHow long resolvers may cache the record3600 seconds

The target must be a hostname, not an IP address. An MX record also should not point at a CNAME alias, because that can create resolution problems and failed delivery. A single server is valid, and its priority number can be any integer permitted by the SMTP specification; a lone record with priority 50 is as usable as one with priority 10.

What MX records do not do

MX records do not store messages, authenticate senders, or decide which mailbox receives a message. They only publish where inbound SMTP connections should go. Usernames, passwords, mailbox quotas, spam filtering, and retrieval protocols are handled by the mail server and related DNS records. A correct MX record can still lead to rejected mail if the receiving server lacks the recipient or blocks the sender.

Configuration mistakes that break delivery

  • Pointing an MX record at an IP address instead of a hostname. DNS MX data must name a host, so an IP literal is invalid.
  • Using a CNAME as the MX target. This is a common cause of failed or unpredictable delivery.
  • Publishing only one MX record for a busy domain. One server is simple, but it removes the backup path that multiple records provide.
  • Mismatched reverse DNS. A diagnostic check can reach the mail server, check its reverse DNS, test for an open relay, and measure response time.
  • Treating priority as a load percentage. Equal priorities share traffic; unequal priorities create primary and backup roles.

It also helps to understand what an IP address is and how it works, because MX records name hosts that must later be resolved to addresses.

Checking MX records and mail server health

Administrators can query MX records with DNS tools and then test the receiving server. A diagnostic connection can check reverse DNS, test for an open relay, and time the response. These checks do not prove that every message will be accepted, but they catch common setup errors such as a wrong hostname, a closed port, or a missing reverse record. When troubleshooting, compare the hostname in the MX record with the server's actual identity and certificate. Mailbox access is a separate layer from MX routing; see the difference between IMAP and POP3 for how clients retrieve messages after delivery.

Security and abuse considerations

Because MX records are public DNS data, anyone can see where a domain receives mail. That visibility is necessary for email to work, but it also means attackers can target the listed hosts. Operators should keep those hosts patched, restrict open relays, and monitor response times. A diagnostic check that verifies reverse DNS and tests for an open relay can reveal basic mistakes, but it is not a full security audit.

Why MX records replaced older mail routing

MX records were not part of the earliest mail system. RFC 821, published in 1982, barely mentioned DNS because the shift from HOSTS.TXT to DNS had not begun. RFC 883, the first description of DNS, appeared in late 1983 and described experimental MD and MF records. DNS transition started in 1983; HOSTS.TXT was slated for retirement at the end of 1985 and was not fully retired until the late 1990s. MX records became the standard way to publish mail destinations as DNS replaced the older host table.

Questions people also ask

Can an MX record point to an IP address?

No. An MX record names a hostname, and the sending server resolves that hostname to an IP address before connecting.

What does a lower MX priority number mean?

It means higher preference. RFC 5321 treats the lowest-numbered record as the most preferred destination.

Do MX records affect outgoing email?

No. MX records guide inbound delivery to a domain. Outgoing mail uses the sender's own SMTP server and its DNS records.

How quickly do MX record changes take effect?

The lookup is made against the authoritative name server, so changes should show up quickly, although cached data can delay some resolvers.

Why would a domain have more than one MX record?

Multiple records provide backup paths and can share load when priorities are equal.

Related pages

  • Organize Email Inbox with Filters and Labels

    Filters and labels turn a crowded inbox into a sorted workspace by routing messages automatically and grouping them by topic. A simple system of folders, rules, and daily review habits keeps important mail visible while archiving the rest.

  • Catch-all email address: what it is and how it works

    A catch-all email address is a mailbox that receives messages sent to any address on its domain, including addresses that do not exist. Businesses use it to avoid losing mail to typos or guessed addresses, while marketers must test and segment these addresses because a catch-all server accepts mail without proving the recipient is real.

  • Read Email Headers: A Practical Guide

    Email headers are the hidden metadata attached to every message. They record the servers, IP addresses, timestamps, and authentication results behind a message. Reading them helps you trace a sender, verify SPF, DKIM, and DMARC, and judge whether a message is trustworthy.

  • How to migrate emails to a new provider

    Migrating email means copying messages and contacts to a new mailbox, then changing DNS so new mail arrives there. Back up first, keep the old account active until tests pass, and update MX, SPF, DKIM, and DMARC records.

  • What Is the Difference Between IMAP and POP3?

    IMAP keeps email on the server and synchronizes changes across phones, tablets, and computers. POP3 downloads messages to one device and usually removes them from the server, so it suits a single computer. Choose IMAP for multi-device access and POP3 only when local storage on one machine matters.

  • PID Controllers in Robotics: How Motion Control Works

    PID controllers in robotics compare a target motion with measured motion and combine proportional, integral, and derivative corrections to calculate a control command. The robot applies that command to a motor or other actuator, then repeats the measurement and correction as new sensor data arrives.

How this page was prepared

Before writing, the topic was researched in the sources below. The page then passed automatic quality checks.

Report a mistake on this page