What Is an MX Record
Learn how MX records direct email to the right mail servers, including priority settings. Includes examples for the DNScale dashboard and API.
An MX (Mail Exchange) record specifies which mail servers are responsible for receiving email for your domain. When someone sends an email to user@yourdomain.com, MX records tell the sending server where to deliver the message.
How MX Records Work
MX records include two key components:
- Priority (preference) - A number indicating server priority (lower = higher priority)
- Mail server - The hostname of the mail server
example.com. 3600 MX 10 mail.example.com.
example.com. 3600 MX 20 backup.example.com.When sending an email to user@example.com:
- Sender's mail server queries MX records for
example.com - Tries the server with lowest priority (10 =
mail.example.com) first - If unavailable, falls back to higher priority servers (20 =
backup.example.com)
Common Use Cases
Single Mail Server
Basic setup with one mail server:
example.com. 3600 MX 10 mail.example.com.Multiple Mail Servers with Failover
Primary and backup servers:
example.com. 3600 MX 10 mail1.example.com.
example.com. 3600 MX 20 mail2.example.com.
example.com. 3600 MX 30 mail3.example.com.Third-Party Email Services
Google Workspace:
example.com. 3600 MX 1 aspmx.l.google.com.
example.com. 3600 MX 5 alt1.aspmx.l.google.com.
example.com. 3600 MX 5 alt2.aspmx.l.google.com.
example.com. 3600 MX 10 alt3.aspmx.l.google.com.
example.com. 3600 MX 10 alt4.aspmx.l.google.com.Microsoft 365:
example.com. 3600 MX 0 example-com.mail.protection.outlook.com.Zoho Mail:
example.com. 3600 MX 10 mx.zoho.eu.
example.com. 3600 MX 20 mx2.zoho.eu.
example.com. 3600 MX 50 mx3.zoho.eu.Load Balancing
Equal priority distributes load:
example.com. 3600 MX 10 mail1.example.com.
example.com. 3600 MX 10 mail2.example.com.
example.com. 3600 MX 10 mail3.example.com.Record Format
| Field | Description | Example |
|---|---|---|
| Name | Domain (usually apex) | @ (apex), subdomain |
| Type | Record type | MX |
| Priority | Server preference (lower = preferred) | 10 |
| Content | Mail server hostname | mail.example.com. |
| TTL | Time to live (seconds) | 3600 |
Adding an MX Record
Using the Dashboard
- Navigate to your zone in the DNScale dashboard
- Click Add Record
- Configure the record:
- Name: Usually
@for the apex domain - Type: Select
MX - Priority: Enter the priority value (e.g.,
10) - Value: Enter the mail server hostname
- TTL: Set the cache duration (default: 3600)
- Name: Usually
- Click Create Record
Using the API
Create an MX record:
curl -X POST "https://api.dnscale.eu/v1/zones/{zone_id}/records" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "@",
"type": "MX",
"content": "mail.example.com",
"ttl": 3600,
"priority": 10
}'Set up Google Workspace MX records:
# Primary MX
curl -X POST "https://api.dnscale.eu/v1/zones/{zone_id}/records" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "@",
"type": "MX",
"content": "aspmx.l.google.com",
"ttl": 3600,
"priority": 1
}'
# Secondary MX
curl -X POST "https://api.dnscale.eu/v1/zones/{zone_id}/records" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "@",
"type": "MX",
"content": "alt1.aspmx.l.google.com",
"ttl": 3600,
"priority": 5
}'API Response:
{
"status": "success",
"data": {
"message": "Record created successfully",
"record": {
"id": "encoded-record-id",
"name": "example.com.",
"type": "MX",
"content": "mail.example.com.",
"ttl": 3600,
"priority": 10,
"disabled": false
}
}
}Best Practices
-
Always have backup MX servers - Use multiple MX records with different priorities for redundancy
-
Use appropriate priority gaps - Leave room between priorities (10, 20, 30) to insert new servers later
-
MX targets must be A/AAAA records - MX records should point to hostnames with A/AAAA records, not CNAMEs
-
Configure reverse DNS - Ensure your mail servers have proper PTR records for deliverability
-
Add SPF, DKIM, and DMARC - Complement MX records with email authentication records
Email Authentication Records
MX records work alongside other records for email security:
| Record Type | Purpose |
|---|---|
| MX | Directs incoming mail |
| TXT (SPF) | Authorizes sending servers |
| TXT (DKIM) | Email signing verification |
| TXT (DMARC) | Policy for failed authentication |
Example complete email setup:
example.com. 3600 MX 10 mail.example.com.
example.com. 3600 TXT "v=spf1 mx -all"
example.com. 3600 TXT "v=DMARC1; p=quarantine; rua=mailto:dmarc@example.com"Testing MX Records
Verify your MX records with dig:
dig MX example.com
# Check specific nameserver
dig MX example.com @ns1.dnscale.euOr use online tools like MXToolbox to verify your email configuration.
Related Record Types
Conclusion
MX records are the foundation of email delivery for your domain. Proper configuration with backup servers, appropriate priorities, and complementary authentication records ensures reliable and secure email communication. DNScale makes managing MX records straightforward, whether you're self-hosting mail or using a third-party provider.