MX DNS entries

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen

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:

What a MX entry like MX example.com. mail.example.com. IN 10 for domain example.com means
Value Part Notes
MX DNS entry type MX entries indicate incoming mail servers
example.com. Name
  • The "name" part of an MX entry specifies the domain or subdomain for which the MX record applies. It defines what email addresses the record is responsible for
  • example.com.: Domain for which the MX record is set - In this case, the main domain
  • The trailing "." in example.com. indicates that this address is final - No stuff can be concatenated. I don't know what that means here
  • For an MX entry, the content part contains the domain name of the actual mail server
mail.example.com. Mail server host
  • Hostname of the mail server responsible for handling incoming email
  • The . indicates again a final address
IN Record class
  • 10 indicates that the record class is the Internet
  • I think this field is usually hidden and I won't mention it in further examples
  • I don't know what it is
10 Priority
  • This is an MX-specific field
  • The lower the value, the higher the priority
  • 10 is a usual value for the default mail server

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 to mail.example.com
  • Email send to user@feedback.example.com will be routed to feedback-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.

See also