DNS record types
MX records and priority
Route email to mail servers and interpret the preference number correctly.
An MX record tells the rest of the internet which servers accept email for your domain. When someone sends mail to [email protected], their mail server looks up the MX records for example.com to know where to connect.
Each MX value has two parts, a preference number and a hostname:
example.com. 3600 IN MX 10 mail1.example.net.
example.com. 3600 IN MX 20 mail2.example.net.
Lower wins
Senders try the lowest number first. Here mail1 gets every delivery attempt. mail2 is only tried when mail1 can’t be reached.
The number is a ranking, not a share. 20 does not mean “send 20 percent of the mail here”. If two records have the same preference, senders pick between them, and that does spread the load.
The target must be a real hostname
The MX value is a hostname, and that hostname must resolve to A or AAAA records directly. Two mistakes to avoid:
- don’t put an IP address in the MX value
- don’t hide the mail hostname behind an HTTP proxy
Mail uses SMTP on port 25, not HTTP. If the mail hostname is proxied through Cloudflare, senders connect to a web proxy that doesn’t speak SMTP, and delivery fails. Mail-related A records must stay DNS-only.
A fallback is a commitment
That mail2 fallback only helps if it’s configured to accept mail for your domain and pass it on safely. An abandoned fallback server becomes a spam magnet or a place where mail quietly disappears. If you’re not going to maintain it, don’t publish it.
Follow the chain
Getting an MX answer back is not the end of the check. Resolve the targets too:
dig MX example.com +short
dig A mail1.example.net +short
dig AAAA mail1.example.net +short
An MX lookup can succeed while delivery fails. The target might have no address. Port 25 might be blocked. The server might reject the recipient. DNS narrows the problem down. It doesn’t test the SMTP conversation.
A domain that receives no mail
If a domain should never receive email, say so explicitly with a null MX: preference 0 and target .:
example.com. 3600 IN MX 0 .
This is the standard way. Don’t make up a fake mail hostname to get the same effect.
Try this: pull the MX set for a domain you use. Sort the targets by preference, resolve each one, and write down which failure would make a sender move to the next server.
Lesson completed