designwithfocus

Domains, hosting & DNS

MX Record vs DNS: One Record Type inside the System

By Design With Focus Team 7 min read
Notebook sketch of a domain name pointing at a mail server

Short answer

DNS is the system that stores name data, and an MX record is one record type inside it that names mail servers. RFC 1035 defines MX as type 15, with a preference and a host name. You add an MX record when mail for that name should reach a server. You do not pick MX instead of DNS.

Last verified against the sources listed below.

Key takeaways

  • RFC 1035 describes the domain system and defines MX as mail exchange, type 15.
  • An MX record holds a preference and the domain name of a host that will accept mail.
  • Lower preference values are preferred when several MX records share an owner name.
  • A and AAAA records map a name to an address. They are not mail routing by themselves.
  • CNAME stores an alias. TXT stores descriptive text. Neither replaces an MX record.
  • RFC 1035 does not set one default TTL for every record type. Do not invent one.

MX record vs DNS is a comparison of a whole system and one row inside it. DNS is the domain name system, and an MX record is the type that names a host willing to accept mail. You add that record inside DNS. You do not replace DNS with it.

RFC 1035 is the specification for how the domain system is implemented. IANA operates key parts of that system, including the root zone. Mail is one use of the data. Web hosting, which is covered in what web hosting is, is another use, usually through address records rather than MX.

DNS is the system

DNS is the system that stores typed records and answers questions about names. RFC 1035 calls it the domain system: a mix of functions and data types, with standard queries, responses, and resource-record formats. New types were expected. MX is one of the types the RFC already defined.

A resource record has a type, a class, a TTL, and RDATA. The meaning of the RDATA depends on the type. The TTL is a field on that record. This guide does not invent a default TTL, because RFC 1035 does not publish one number for every type.

A zero TTL means the record is only for the transaction in progress and should not be cached. The SOA MINIMUM field is a lower bound on TTL when records are copied into a response.

How the internet works is the wider path a lookup takes. Cloudflare’s caching article adds one related fact: DNS servers cache DNS records so a later lookup can be answered from that cache. That is a cache of DNS data. It is not the MX record itself.

An MX record names mail servers

An MX record names a mail exchanger and ranks it against other exchangers for the same name. In RFC 1035, type MX is value 15, “mail exchange.” The RDATA is a 16-bit PREFERENCE plus EXCHANGE, a domain name of a host willing to act as a mail exchange for the owner name. Lower preference values are preferred.

The RFC also says MX records cause type A additional section processing for the exchange host. The mail server’s address is not packed into the MX RDATA as a 32-bit number. The address is a separate record on that host name.

Cloudflare’s DNS record types say a mail exchange (MX) record is required to deliver email to a mail server. That matches the RFC’s role. It does not make MX a second naming system. The record still lives in the DNS zone for the domain.

Older types MD and MF are marked obsolete in RFC 1035, with a note to use MX. If you see them in an old file, they are not the current mail record.

Record types you will see beside MX

Use this table only for types defined on the pages opened for this guide. A, CNAME, MX, and TXT are in RFC 1035. AAAA is on Cloudflare’s chart and is not in that RFC’s type list. No row here is a TTL default.

Type What it stores Where it is defined
A A 32-bit Internet address. A host with several addresses has several A records. RFC 1035. Cloudflare maps A to IPv4.
AAAA One or more IPv6 addresses for the name. Cloudflare’s record-type page. Not in the RFC 1035 type list.
CNAME The canonical, or primary, name for an alias. RFC 1035. Cloudflare: a name pointing at another domain name.
MX A preference plus the domain name of a mail exchange host. RFC 1035. Cloudflare: required to deliver email to a mail server.
TXT One or more character strings of descriptive text. The meaning depends on the domain. RFC 1035. Cloudflare often uses TXT to show domain control before a certificate.

Cloudflare says A and AAAA are the records that map a name to an address, and that at least one address record is required for each domain on its service. Those records answer “where is this host?” MX answers “which host will take mail?” A website can have A or AAAA records and no MX. A mail domain needs an MX if you want the RFC 1035 mail path, plus an address record for the exchange host.

CNAME is an alias: the owner name is the alias, and the RDATA is the canonical name. TXT holds text. Cloudflare says TXT records are commonly used there to demonstrate domain ownership before an SSL/TLS certificate. That is a use of text, not a mail exchanger.

Which to choose, and when

Choose DNS as the place you edit. Then choose the type for the question you need to answer. The choices below are about record types, not about replacing the system.

  • Choose an MX record when a mail server should accept mail for the name. Set the exchange to a host name, and give it a preference. Lower means preferred.
  • Choose A when that host needs an IPv4 address. Choose AAAA when it needs an IPv6 address. Cloudflare defines both jobs on its record page.
  • Choose CNAME when the name should be an alias of another name, and follow your DNS host’s rules about other types on that same name.
  • Choose TXT when you need descriptive text, such as the ownership check Cloudflare describes. Do not put a mail server only in TXT and expect MX behavior.

If the site and the mail live on different companies, the address records can point at the web host while the MX records point at the mail host. That split is normal. It is still one DNS zone with several types. The web server and the mail server do not have to be the same machine.

Mistakes that mix the system and the record

The errors below come from treating MX as a rival to DNS, or from copying a number the RFC never set.

Mistake What the sources actually say
“MX instead of DNS” MX is type 15 inside the domain system RFC 1035 specifies.
Putting an IP address in the MX exchange field EXCHANGE is a domain name. The address is an A or AAAA record.
Assuming one global TTL TTL is per record. Zero means do not cache past this transaction.
Copying Cloudflare’s 300-second Auto TTL onto MX That 300 seconds is for proxied A or AAAA records on Cloudflare, not an MX default in the RFC.
Using a CNAME article’s alias as the mail server CNAME names a canonical host. MX names a mail exchange. They are different types.

When mail fails, check three things in the zone: an MX record exists, its exchange is a name, and that name has an address record. When the website fails, check A or AAAA. Those are different questions inside the same system.

Frequently asked questions

Does a domain need an MX record if it never sends mail?

RFC 1035 defines MX as the record that names a host willing to accept mail for the owner name. If nothing should accept mail, you have no delivery target to publish. Cloudflare's record guide still says an MX record is required to deliver email to a mail server, which is about delivery, not about an empty domain. Leaving MX unset means there is no published mail exchange. That is a choice about mail, not a choice to leave DNS.

What does a lower MX preference number mean?

RFC 1035 says the preference is a 16-bit integer, and lower values are preferred among MX records at the same owner name. A preference of 10 is tried before a preference of 20 when both are present. The number is not a port, a priority in milliseconds, or a TTL. Publishers often use gaps, such as 10 and 20, so a value can be inserted later. The RFC does not require those gaps.

Is the mail server's address stored inside the MX record?

The MX RDATA in RFC 1035 is a preference plus EXCHANGE, and EXCHANGE is a domain name, not a 32-bit address. The RFC says MX records cause type A additional section processing for that host. The address lives in an A record, defined there as a 32-bit Internet address, or in an AAAA record for IPv6 on Cloudflare's record chart. If the exchange name has no address record, mail software has a name and nowhere to connect.

Can a CNAME and an MX record share the same owner name?

RFC 1035 defines CNAME as the canonical name for an alias. The owner name of a CNAME is the alias. This guide does not add a extra ban beyond that definition. Cloudflare's record page says a CNAME maps a name to another domain name, and that queries for other types on a proxied CNAME name are not supported in its example. Read the DNS host's rule for your zone before you place both types on one label.

Where does a TTL of 300 seconds come from?

It is not an MX default in RFC 1035. Cloudflare's record-type page says that when an A or AAAA record is proxied, TTL defaults to Auto, which is 300 seconds, and that a DNS-only record can use a custom TTL. That is a Cloudflare proxy setting for address records. RFC 1035 treats TTL as a field on the record. A zero TTL means the record should not be cached beyond the transaction in progress. Do not copy 300 onto an MX record.

Sources