MX Record
A DNS Mail Exchange (MX) record is a type of resource record in the Domain Name System that specifies the mail server responsible for accepting email messages on behalf of a domain name. MX records direct email to the proper servers and include priority values that determine the order in which mail servers should be contacted.
How it works
When someone sends an email to your domain (e.g., user@example.com), their email server needs to know which mail server should receive the message. MX records provide this information by mapping your domain name to one or more mail servers, along with priority values that determine the order in which they should be tried.
Key Points
- MX records consist of two parts: a priority value and a mail server hostname
- Lower priority numbers indicate higher preference (e.g., priority 10 is tried before priority 20)
- Multiple MX records provide redundancy and load balancing for email delivery
- MX records must point to a hostname (A or AAAA record), never directly to an IP address
- If no MX record exists, some mail servers will attempt delivery using the domain's A record as a fallback
Common Use Cases
- Email Server Configuration: Directing email traffic to your organization's mail servers, whether self-hosted or using services like Gmail, Microsoft 365, or other email providers
- Redundancy and Failover: Setting up multiple MX records with different priorities ensures email delivery continues even if the primary mail server is temporarily unavailable
- Load Balancing: Configuring multiple MX records with equal priority distributes incoming email across multiple servers, preventing any single server from being overwhelmed
- Spam Filtering: Pointing MX records to spam filtering services (like Cloudflare Area 1 or Barracuda) before routing clean email to the actual mail server
code Example Configuration
| Type | Host / Name | Value / Points to | TTL |
|---|---|---|---|
| MX | @ | 10 mail1.example.com | 3600 |
| MX | @ | 20 mail2.example.com | 3600 |
| MX | @ | 30 mail3.example.com | 3600 |
| A | mail1 | 192.0.2.10 | 3600 |
* MX records include a priority value (lower = higher priority) and a mail server hostname. Multiple records provide redundancy.