What is mx record

Last updated: April 2, 2026

Quick Answer: An MX record is a DNS record type that specifies which mail servers are responsible for receiving emails on behalf of a domain. Defined in RFC 1035, MX records contain a mail server hostname and priority value that enable the SMTP protocol to route over 300 billion emails daily to correct destinations. Every domain that receives email requires properly configured MX records. Without them, emails cannot reach their intended recipients, making them fundamental to email infrastructure.

Key Facts

Overview

An MX record is a specific type of DNS resource record that serves a single, critical function: directing email to the correct mail servers for a domain. The acronym MX stands for Mail Exchange, and these records are one of the fundamental components of internet email infrastructure. When someone sends an email to [email protected], the sender's mail server performs a DNS query to find the MX records for example.com. These records contain the hostnames and priority values of servers configured to receive mail for that domain. The SMTP (Simple Mail Transfer Protocol) system, which handles email transmission, relies entirely on MX records to determine where to deliver messages.

MX records were standardized in RFC 1035, published in 1987, making them one of the older DNS record types. Despite their age, they remain essential and largely unchanged. The basic structure of an MX record is simple: it contains a hostname (the mail server address) and a preference number (priority value). The preference number is crucial because it allows organizations to designate primary and secondary mail servers, enabling automatic failover if the primary server becomes unavailable. This elegant system has proven so effective that it continues to power email delivery across billions of messages daily.

Technical Structure and Function

An MX record consists of two main components: the mail server hostname and the preference value (priority). The preference value ranges from 0 to 65,535, with lower numbers indicating higher priority. When a mail server needs to send an email, it queries the DNS system for all MX records associated with the destination domain. It then attempts delivery to the mail server with the lowest preference value first. If that server is unreachable or rejects the connection, the sending server waits and retries that same server. If the primary server continues to be unavailable, the sender eventually moves to the next lowest preference value and attempts delivery there.

The complete DNS lookup for MX records occurs through a hierarchical system. A mail server first queries a DNS resolver, which may cache results or query root nameservers. The resolver works down the domain hierarchy to find the authoritative nameserver for the domain in question. For example.com, the resolver would eventually reach the nameserver authoritative for example.com and request its MX records. This authoritative nameserver returns all MX records configured for example.com, including their respective preference values.

A typical MX record entry looks like this in zone file format: "example.com MX 10 mail1.example.com" and "example.com MX 20 mail2.example.com." This configuration means mail servers will attempt to deliver to mail1.example.com first (priority 10), and only if that fails, attempt mail2.example.com (priority 20). Large organizations may configure 3-5 MX records with different priorities across geographically distributed data centers. The redundancy provided by multiple MX records is critical for email reliability, ensuring that temporary mail server outages don't prevent email delivery.

The SMTP protocol (defined in RFC 5321) specifies exactly how mail servers use MX records. When an SMTP client connects to a mail server to deliver message, the server performs the MX lookup and attempts connections in priority order. RFC standards specify that mail servers should retry failed deliveries for at least 24 hours, with backoff periods that extend to hours between attempts. This persistence is why emails can eventually be delivered even when mail servers are temporarily offline.

Practical Configuration and Examples

Setting up MX records is straightforward for anyone with domain access. The process involves accessing the DNS management interface (typically through a domain registrar's control panel) and adding MX records with the appropriate mail server hostname and priority value. For small businesses or individuals using third-party email services like Gmail or Microsoft 365, the email provider typically supplies the exact MX record values to configure.

For a company named "Acme Corp" using Gmail for business email, the configuration would include Google's MX records: MX 5 gmail-smtp-in.l.google.com, with backup servers at priority 10, 20, 30, and 40. These specific hostnames are Gmail's mail exchange servers that Acme Corp's domain should point to. Once configured, when an external sender emails [email protected], their mail server queries the MX records for acmecorp.com and finds Google's mail exchange servers, delivering the message there.

DNS propagation of MX record changes typically takes 24-48 hours globally, though many systems update within minutes. This is important when switching email providers, as both old and new mail servers may need to accept messages for your domain during the transition period. Many organizations configure the old mail server to forward messages to the new server temporarily to prevent any email loss.

Common Misconceptions and Important Distinctions

A frequent misunderstanding is confusing MX records with A records. While an A record maps a domain name (like example.com) to an IP address and directs web traffic, an MX record specifically directs email traffic to mail servers. A domain must have an A record for its website to work and can have completely separate MX records for email. It's entirely possible for example.com's A record to point to a web server at 192.168.1.100 while MX records point to mail servers at entirely different IP addresses or even third-party email services.

Another misconception is that MX records store email messages or that they are involved in email security. In reality, MX records are purely routing instructions that are typically less than 100 bytes in size. They contain no email content and serve no security function themselves. Email security is handled by separate mechanisms: SPF (Sender Policy Framework) records specify which servers can send email from your domain, DKIM (DomainKeys Identified Mail) provides cryptographic verification, and DMARC (Domain-based Message Authentication) creates policies based on these standards. These are distinct from MX records and address different aspects of email security.

Some people mistakenly believe that pointing an MX record to a server automatically configures that server to receive mail. In truth, the mail server itself must be independently configured to accept and process mail for the domain. The MX record simply tells other mail servers where to attempt delivery. If the mail server at that address isn't properly configured with mailboxes, user accounts, or forwarding rules, it will reject the delivery or the mail will be lost.

Troubleshooting and Verification

When email isn't reaching a domain, checking MX records is often the first troubleshooting step. Command-line tools make this easy: "nslookup -type=MX example.com" (Windows) or "dig example.com MX" (Linux/Mac) will display all MX records for a domain. MX Toolbox and similar online services provide web-based MX record lookups that also check for common configuration problems. Professional email administrators regularly test MX configurations to ensure they're working correctly and monitoring services can alert them if MX records become misconfigured.

Common MX record issues include typos in mail server hostnames, incorrect priority values, or pointing to servers that don't exist or aren't properly configured. Another issue occurs during email provider migrations when old MX records are deleted before the transition is complete, causing email loss. Best practices include verifying MX records before making changes, maintaining multiple MX records for redundancy, monitoring that MX records haven't been accidentally modified, and ensuring mail servers are properly secured with authentication protocols.

Related Questions

How do I check my domain's MX records?

You can check MX records using command-line tools: type "nslookup -type=MX yourdomain.com" on Windows or "dig yourdomain.com MX" on Linux/Mac. Online tools like MX Toolbox also provide web-based lookup interfaces. These tools will display all MX records configured for your domain including their priority values and target mail servers.

What happens if MX records are missing or misconfigured?

Without MX records, emails to your domain cannot be delivered and will bounce back to the sender. Misconfigured MX records pointing to non-existent or improperly configured servers will cause the same result. Mail servers will retry for 24+ hours according to RFC standards, but if MX records remain incorrect, delivery ultimately fails and senders receive an error notification.

Can I have multiple MX records with the same priority?

Yes, multiple MX records can have identical priority values. When this occurs, RFC standards specify that mail servers should select among them randomly or in round-robin fashion, distributing load across multiple mail servers. This technique is used by large organizations to balance email traffic across multiple servers, such as Gmail using multiple servers all with priority 5.

How long do MX record changes take to take effect?

MX record changes propagate through DNS globally over 24-48 hours, though many systems update within minutes. The variation depends on DNS cache TTL (time-to-live) values, which administrators can set lower during transitions. During migration periods, it's wise to maintain both old and new mail servers to receive messages until propagation is complete.

What's the difference between MX records and email authentication?

MX records route email to the correct server but provide no security. SPF, DKIM, and DMARC are separate authentication mechanisms that verify email legitimacy and prevent spoofing. SPF records authorize which servers can send from your domain, DKIM adds cryptographic signatures, and DMARC creates policies based on these standards. All are necessary for modern email security.

Sources

  1. Wikipedia: MX RecordCC-BY-SA
  2. RFC 5321: Simple Mail Transfer ProtocolPublic Domain
  3. RFC 1035: Domain Names Implementation and SpecificationPublic Domain
  4. JPNIC: MX Record ExplanationPublic Domain