MX Record
DNS record that specifies which mail servers receive email for the domain.
What is an MX record
The MX (Mail Exchange) record defines which mail servers will receive email
for your domain. When someone sends an email to user@example.com, the sending
server makes a DNS query for the MX records of example.com and delivers the
message to the listed mail servers.
Structure of an MX record
example.com. IN MX 10 mail1.example.com.
example.com. IN MX 20 mail2.example.com.
example.com. IN MX 30 fallback.example.net.
Fields:
- Priority (10, 20, 30) — lower number = higher priority. The sending server tries the most preferred entries first.
- Hostname — must point to a hostname that has an A/AAAA record. It is not allowed to point to a CNAME or directly to an IP.
How it works
- The sending server makes a DNS query: «MX records for example.com».
- It receives the list with priorities.
- It tries the lowest priority first. If that fails (connection refused, timeout), it tries the next one.
- Once connected, it performs SMTP delivery.
Multiple MX records with the same priority
If you have two MX records with the same priority, the sending server distributes them randomly/round-robin — useful for load balancing between equivalent mail servers.
Google Workspace example
example.com. IN MX 1 aspmx.l.google.com.
example.com. IN MX 5 alt1.aspmx.l.google.com.
example.com. IN MX 5 alt2.aspmx.l.google.com.
example.com. IN MX 10 alt3.aspmx.l.google.com.
example.com. IN MX 10 alt4.aspmx.l.google.com.
Common mistakes
- MX pointing to an IP or to a CNAME — instead of a proper A/AAAA hostname.
- Missing PTR/Reverse DNS for the mail servers — causes rejections.
- Wrong priorities — avoid random numbers. Use 10, 20, 30 or whatever your provider specifies.
- Missing MX record — some sending servers will fall back to the A record (deprecated behavior), others will reject the mail.