MX DNS entries
MX (Mail Exchange) DNS records are used to specify the mail server responsible for receiving email messages on behalf of a domain.
Introduction
When someone sends an email to an address within a particular domain (e.g., user@example.com), the sending mail server looks up the MX records for the recipient's domain to determine where to deliver the email. The MX records point to one or more mail servers that are designated to handle incoming email for that domain.
MX records consist of two main components:
- Priority: This is a numeric value indicating the priority of the mail server. Lower values indicate higher priority. When multiple MX records are present for a domain, the sending mail server will attempt to deliver email to the server with the lowest priority first. If that server is unavailable, it will try the next one with a higher priority, and so on
- Mail server hostname: This is the domain name of the mail server responsible for receiving emails for the domain. It can be either a fully qualified domain name (FQDN) or an IP address.
Complete example
How a 'complete' DNS MX record might look like:
Value | Part | Notes |
---|---|---|
MX | DNS entry type | MX entries indicate incoming mail servers |
example.com.
|
Name |
|
mail.example.com.
|
Mail server host |
|
IN
|
Record class |
|
10
|
Priority |
|
Subdomains
You can have separate MX entries for subdomains, and these entries operate independently of each other - Quite handy to separate email that is handled by different entities.
As an example, consider these MX entries:
example.com. MX 10 mail.example.com. feedback.example.com. MX 10 feedback-mail.example.com.
- Email send to
user@example.com
will be routed tomail.example.com
- Email send to
user@feedback.example.com
will be routed tofeedback-mail.example.com
This functionality is often deployed to separate email related to different functions and providers. E.g.:
- Regular email:
example.com
- Replies to newsletters:
mailcamp.example.com
- Bounces to fulfillment partner emails:
edesk-bounces.example.com
.
Example
Consider these two entries for domain example.com
with Edesk being a customer service platform:
MX edesk-bounces feedback-smtp.us-east-1.amazonses.com 10 MX example.com mx.transip.email 10
Events:
- En email is send through Edesk with the mail server for bounces being specified as
edesk-bounces
- The receiving mail server bounces the email by sending it to
ffdslfslsfsfs@edesk-bounces.example.com
- Since the bounce email address is for subdomain
edesk-bounces
, it follows the MX entry for that same subdomain.
What this example shows: There is no conflict between these two MX entries: The first one is only invoked in specific situations - Neat!
FQDN
Ideally, a subdomain MX entry should have a fully qualified domain name. Usually, DNS providers will automatically append parent domain names if they are missing, but probably better to not having to relay on that.
Debugging & testing
Examples:
dig
dig MX example.com dig MX edesk-bounces.example.com
nslookup
nslookup > set type=mx > example.com
telnet
Check if you can reach the mail server. E.g.:
telnet mail.example.com 25
mxtoolbox.com
Use mxtoolbox.com - I quite like it
Case: edesk-bounces.example.com not found (2024.12)
There were some issues getting the DNS entries for edesk-bounces.example.com
correct.
After (in the end) contacting TransIP, the outcome was, that different providers use slightly different syntaxis for various DNS entries. Thanks to contant from the helpdesk of TransIP (2024.12.20), I got the syntaxis right and the problem has been solved.