Skip to content
Log In Sign Up info@muvcloud.com

What an MX Record Does

When a mail server has a message for a mailbox on example.com, it asks DNS for the MX records of example.com. The answer names one or more mail hosts. The sending server looks up the address of the host with the best priority and delivers the message there on port 25. Without a working MX record, mail for the domain cannot be routed reliably. Other record types are explained in DNS record types.

What One Looks Like

In zone file form, with the mail host's own address record:

example.com.        3600  IN  MX  10 mail.example.com.
mail.example.com.   3600  IN  A   203.0.113.10
PartMeaning
example.com.The mail domain
3600TTL in seconds
10Priority
mail.example.com.The mail host

In a DNS provider's panel you choose the type MX, set the name to the domain itself, enter the mail host as the value, and the priority in its own field. When a mail service hosts your mailboxes, it gives you the exact values to enter.

Priority Numbers

The lowest number has the highest priority. Senders try the host with the lowest number first and move to the next one only if it cannot be reached. Two records with the same number share the load at random. The numbers themselves are arbitrary: 10 and 20 work the same as 1 and 2, and the gaps leave room to add a host later.

example.com.  3600  IN  MX  10 mail1.example.com.
example.com.  3600  IN  MX  20 mail2.example.com.

A backup MX only helps if it is set up to accept and hold mail for your domain. A second record that points to a host which rejects the mail adds nothing.

Rules for the Target

  • A host name, never an IP address: the value must be a name such as mail.example.com.
  • The name needs an A or AAAA record: add it in the same step.
  • Not a CNAME: the DNS standards do not allow an MX target to be an alias, and some senders refuse it. See A record vs CNAME.
  • Not behind a web proxy: if your DNS provider can proxy records, as Cloudflare can, the mail host's record must be DNS-only, because the proxy does not carry mail.

Check MX Records with dig

dig +short MX example.com
dig +short A mail.example.com

The first command prints each record as a priority and a host name, for example 10 mail.example.com.. The second must return the mail host's address. To see the TTL as well, run dig MX example.com without +short; see dig command.

TTL and Changing Mail Hosts

An MX record is cached like any other record for the length of its TTL. Before you move mail to a new host, lower the TTL a day in advance, keep the old server accepting mail until the old records expire everywhere, then raise the TTL again. The reasoning is in DNS TTL.

Domains That Receive No Mail

A domain without any MX record is not safe from mail: senders fall back to its A or AAAA record. To state that a domain accepts no mail at all, publish a null MX (RFC 7505), a record with priority 0 and a lone dot as target. It must be the domain's only MX record:

example.com.  3600  IN  MX  0 .

Common Mistakes

  • Missing final dot in a zone file: mail.example.com without the dot becomes mail.example.com.example.com.
  • Old records left behind: records of a previous mail service still compete by priority.
  • Target without an address: the host name in the MX record does not resolve.
  • Expecting MX to help sending: MX records only route incoming mail. Sending needs SPF, DKIM, and reverse DNS for the sending server (see what is reverse DNS) and an open port 25 or a relay.

Updated:

Linux VPS with Full Root Access

MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.

Cloud VPS Plans Starting at2.99 $/mo Cheap Linux VPS

No Limits on Service or Support

You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

Support specialist
  • 100% customer satisfaction goal
  • Our own hardware
  • 24/7 ticket and email support
  • 4 countries with locations