
MX, DNS, and mail routing explained
Email addresses are readable strings, but the system that routes them relies on DNS and SMTP. When a message leaves a sender, DNS identifies the destination and SMTP handles the transfer.
This explains the main pieces in the order they are used.
DNS: the lookup layer
The Domain Name System maps names to records. Email commonly depends on:
- MX - identifies mail exchangers for a domain.
- A / AAAA - gives IPv4 or IPv6 addresses for the hostnames named by MX records.
- TXT - commonly carries SPF and DMARC policies.
- CNAME - often used by providers for delegated records such as DKIM selectors.
Two operational details matter a lot:
- Authority - edit DNS where the domain's authoritative nameservers point, not necessarily at the registrar.
- TTL - resolvers may cache an old answer until its time-to-live expires, so a DNS change is not instantly visible everywhere.
MX records: which server gets the mail
An MX record contains a hostname and a preference value.
example.com. MX 10 mail1.example.com.
example.com. MX 20 mail2.example.com.
Lower preference numbers are tried before higher ones. Multiple MX records with the same preference are equally preferred; SMTP clients may choose among them and should be able to try alternative destinations when delivery fails.
An MX target is a hostname, not an IP address. That hostname then resolves to A or AAAA records.
Subdomains are separate DNS names. A parent domain's MX configuration is not automatically inherited by a subdomain.
What happens when there is no MX record?
SMTP has a standards-defined fallback. If no MX record exists for a destination domain, the domain is treated as if it had an implicit MX pointing to itself, and the sender can try the domain's A or AAAA address. This is legacy-compatible behavior from SMTP itself, not a substitute for publishing proper MX records when the domain is meant to receive mail.
Looking up your own records
dig MX example.com +short
nslookup -type=mx example.com
Compare the results with the values your mail provider publishes.
SMTP: the delivery conversation
After choosing a destination, the sending server opens an SMTP connection and exchanges commands roughly like this:
- Greeting and server identification.
MAIL FROM- the envelope sender or return path.RCPT TO- the recipient address.- The receiving server accepts, rejects, or temporarily defers the recipient.
DATA- the message content is transferred.- The receiving server gives a final response.
The broad SMTP response families are:
- 2xx - success.
- 4xx - temporary failure; the sender should queue and retry.
- 5xx - permanent failure for that attempt; a change is normally required before retrying.
SMTP standards recommend retrying temporary failures over a period that can extend for several days. Individual providers may use their own retry schedules.
The important distinction is that server acceptance is not Inbox placement. After accepting responsibility for the message, the receiving system can still apply spam filtering, quarantine, forwarding, or mailbox rules.
SPF, DKIM, and DMARC: authentication and policy
These records do not tell senders where to route inbound mail. They help recipients evaluate outbound mail claiming to use a domain.
SPF publishes which systems are authorized to use a domain in the SMTP envelope identity. Forwarding can break SPF because the forwarding system's IP may not be authorized by the original domain.
A domain must not publish multiple separate SPF records beginning with v=spf1 at the same name. RFC 7208 specifies that more than one selected SPF record produces a permanent SPF error.
DKIM adds a cryptographic signature. The receiving server can verify that the message was signed by a system holding the private key for the signing domain and that the signed parts of the message were not modified after signing. DKIM does not by itself prove the human identity of the sender.
DMARC checks whether an SPF-authenticated or DKIM-authenticated domain aligns with the domain visible in the message's From header. The domain owner can publish a policy such as p=none, p=quarantine, or p=reject for messages that fail DMARC.
Current large-sender requirements are stricter than they were before 2024:
- Gmail requires SPF or DKIM for all senders to personal Gmail accounts. Senders above 5,000 messages per day must use SPF, DKIM, and DMARC, and marketing/subscribed mail must support one-click unsubscribe.
- Yahoo requires SPF or DKIM for all senders and SPF, DKIM, and DMARC for bulk senders, plus easy unsubscribe for marketing mail.
- Outlook.com began enforcing SPF, DKIM, and DMARC for domains sending more than 5,000 messages per day to its consumer service on May 5, 2025.
The path end to end
- The sending system receives the outgoing message.
- It looks up the recipient domain's MX records.
- It chooses the most-preferred usable MX host and resolves its A or AAAA records.
- It connects using SMTP.
- The receiving system evaluates the recipient, policy, authentication, reputation, and other checks.
- It accepts, temporarily defers, or permanently rejects the message.
- If accepted, downstream filtering and mailbox rules determine where the message appears.
Misconfigurations that commonly break mail
- Old provider MX records left in place. If old records are equally or more preferred, or if the preferred provider is unavailable, some mail can still be routed to the old system.
- Records edited at the wrong DNS provider. Changes have no effect if that provider is not authoritative.
- Changes judged before caches expire. TTL controls how long old answers may remain cached.
- MX pointing directly at an IP address. MX data must name a host.
- Multiple SPF records. More than one
v=spf1record at the same name produces an SPF permanent error. - A DMARC reject policy deployed before legitimate senders are correctly aligned. Legitimate outbound mail can then fail DMARC and be rejected by receivers that enforce the policy.
- Assuming subdomains inherit the parent domain's mail routing. They do not automatically inherit MX records.
Checking whether it works
DNS tells you what should happen. An end-to-end send tells you what actually happens.
Send a test message to an address on the domain, then compare the provider-level delivery status with the mailbox itself.
- A rejection can point to the recipient, routing, policy, or sender-side problem - use the diagnostic code rather than guessing from the word "bounced."
- A delivery event means the recipient mail server accepted the message.
- A successful delivery event with no visible message points you toward filtering, quarantine, forwarding, or mailbox rules.
Frequently asked questions
How long do MX changes take to take effect?
It depends mainly on the TTL values that resolvers previously cached. Some users may see the new answer quickly while others continue using the cached answer until it expires.
Can I have MX records at two providers at once?
Yes, but understand the preference values. With different preferences, the lower-numbered provider is normally preferred and the other behaves as a fallback. Equal-preference records can distribute delivery across both providers. Running two unrelated mailbox systems this way is usually undesirable unless you designed the routing intentionally.
Do I need SPF, DKIM, and DMARC to receive mail?
Not for basic inbound routing. They primarily authenticate mail your domain sends. Your receiving provider may have its own security requirements, but MX is what identifies where inbound mail should go.
Why does my website resolve while mail still bounces?
Website DNS and mail DNS are different. A working web A or AAAA record does not prove that the domain has the right MX configuration or that the mail server accepts the recipient.
What is the difference between MX and SMTP?
MX is DNS data that identifies a mail destination. SMTP is the protocol used to transfer the message.
To check a domain's inbound routing end to end, send a test message and compare the delivery status with the mailbox.
Keep learning
More email delivery guides
Email delivery
Why Am I Not Receiving Emails? Causes and How to Find Yours
Not getting emails? Start with five quick checks for Gmail, Outlook and iPhone, then find the cause: filtering, rules, a full mailbox, forwarding or DNS.
Email delivery
Gmail Not Receiving Emails? How to Find the Cause
Gmail not receiving emails? Search Spam and Trash, check storage, blocked senders, filters and forwarding, then send a test email to find the cause.
Email delivery
Outlook Not Receiving Emails? Fixes in the Order That Works
Outlook not receiving emails? Check Junk Email, the Other tab, blocked senders, rules and storage, then send a test email to find the cause.
Try it yourself
Check whether your inbox can receive email
Send a free test email to your inbox and inspect the delivery timeline in seconds.
Send a free test email