What an MX record looks like
An MX (mail exchanger) record is a DNS record with two parts: a priority (RFC 1035 calls it the preference), a number from 0 to 65535 where lower is preferred, and a host name, the mail server that accepts email for the domain. A domain can have several. In a DNS zone file they look like this:
; name TTL class type priority mail server
example.com. 3600 IN MX 10 mx1.mailhost.example.net.
example.com. 3600 IN MX 20 mx2.mailhost.example.net.The same records from the command line:
$ dig +short MX example.com
10 mx1.mailhost.example.net.
20 mx2.mailhost.example.net.| Field | Example | What it is |
|---|---|---|
| Name | example.com (@ at most DNS hosts) | The domain the record receives mail for: the part after the @ in ada@example.com. |
| TTL | 3600 | How many seconds resolvers may cache the answer. A change can take this long to reach every sender. |
| Priority | 10 | Which server senders try first. Lower numbers first. |
| Mail server | mx1.mailhost.example.net | A host name with its own A or AAAA record. Never an IP address and never a CNAME. |
How MX priority works
- Lowest number first. A sender sorts the records by priority and tries the lowest number. If that server doesn't answer, it tries the next.
- Equal numbers share the load. RFC 5321 says a sender must pick among records with the same priority at random, so two servers at
10each get about half the mail. - Only the order matters.
10and20behave exactly like1and2. Providers leave gaps so you can add a server in between later. - A backup is a real mail server. A higher-numbered MX receives mail whenever the first one is unreachable, so it must accept and filter mail for your domain like the primary does.
Most hosted mailbox providers give you one record, or several with set priorities. Copy them exactly as given rather than choosing your own numbers.
What MX records do and don't do
MX records only say where mail to a domain goes. Changing them moves your inbox, not your sending: the email your app sends goes out through your email provider whatever your MX records say. Whether that mail is trusted is down to SPF, DKIM and DMARC, which are TXT records and don't depend on MX.
| Which domain's MX is used | |
|---|---|
Email people send to you@example.com | example.com |
| Replies to your app's emails | The Reply-To domain, or the From domain if there's no Reply-To |
| Bounces and delivery reports for your app's emails | The return-path (envelope sender) domain, which your email provider usually runs |
| Email your app sends | None of yours: each recipient's domain's MX |
- SPF can use MX. The SPF
mxmechanism authorizes the servers your MX records point to. It's only right when those same servers send your mail, and it counts toward SPF's limit of 10 DNS lookups. Hosted inboxes usually send from other servers and give you aninclude:instead. Check your record with the SPF checker. - DKIM and DMARC don't use MX at all. They're TXT records under
_domainkeyand_dmarc.
No MX record, null MX and subdomains
- No MX record. RFC 5321 says a sender then treats the domain's own A or AAAA record as an implicit MX with priority 0. A web server rarely accepts mail, so mail to the domain usually fails. If the domain has no address record either, there is nowhere to deliver.
- Null MX. A single record with priority
0and host.(RFC 7505) says the domain accepts no mail at all, so senders fail at once instead of retrying for days. It's right for domains that never receive. RFC 7505 says not to publish one on a domain you use in From or as a return path: receivers often reject mail whose return address can't receive. - Subdomains don't inherit MX. Records belong to one exact name, so
notifications.example.comhas no MX just becauseexample.comdoes. If you send from a subdomain without an MX or Reply-To, replies to it have nowhere to go. - A CNAME is followed first. If a name is a CNAME, senders look up the MX of its target. That's why a return-path CNAME such as
rp.example.compointing to your email provider sends bounces to the provider, which processes them for you.
Common MX record mistakes
| Mistake | What happens | Fix |
|---|---|---|
MX points at an IP address (10 203.0.113.10) | RFC 5321 says the record must contain a domain name, so many senders can't use it. | Add an A record such as mail.example.com for the IP, and point the MX at that name. |
| MX points at a CNAME | RFC 2181 says an MX target must not be an alias; some senders won't follow it. | Point the MX at the host name the CNAME resolves to. |
Domain added twice (mx1.mailhost.example.net.example.com) | Some DNS hosts treat a value without a trailing dot as relative and append your domain, so the host doesn't exist. | Enter the full host name, with a trailing dot if your DNS host's help says so, then look it up again. |
| Old provider's records left in place | Mail is split between old and new servers (equal priority), or goes to the old one whenever the new one doesn't answer. | Remove the old provider's MX records once the new ones work. |
Receiving service added at the root (@) instead of a subdomain | All mail to the domain, including your team's mailboxes, now goes to that service. | Put app inbound on its own subdomain, such as inbound.example.com, and keep the root pointed at your mailbox provider. |
| Mail server name proxied through a CDN | The name answers with the CDN's IP addresses, which don't accept mail. | Set the mail server's own A record to DNS only. Cloudflare's version of this is the common one. |
| Null MX on a domain you send from | Receivers can reject your mail because its return address can't receive. | Remove the null MX, or send from a domain that receives. |
Requirements from RFC 5321, section 5.1, RFC 2181, section 10.3 and RFC 7505.
How to add an MX record
Every DNS host asks for the same four things: the type (MX), the name or host (@ for the domain itself, or a subdomain such as inbound), the mail server's host name, and the priority. Use the exact values your mailbox or inbound provider gives you, save, then run the lookup above. Until the old record's TTL runs out, some senders may still use the old answer.
Step-by-step guides for the common DNS hosts, with screenshots:
- Cloudflare: MX records are always DNS only, and Email Routing's MX records are locked.
- GoDaddy: the Name, Priority and Value fields, and why to leave the root's MX alone.
- Namecheap: MX records live under Mail Settings, set to Custom MX.
- Bluehost: the DNS tab, removing the default MX record, and cPanel's Email Routing setting.
To receive email in your app with Groundmail, add mx.groundmail.dev at priority 10 on a subdomain such as inbound.example.com. Mail to that subdomain arrives as a signed webhook and through the same API you send with, and your team's mailboxes on the root domain stay where they are.