Blog / How the internet works /

MX records explained

You can have a perfect website and still lose every customer email. When someone writes to hello@yourbusiness.com, nothing about your web hosting decides where that message goes. A small record in your DNS does. That record is the MX record.

An MX (Mail Exchanger) record tells the internet which mail servers accept email for your domain, and in what order to try them. It’s the postal sorting instruction attached to your address.

The analogy: the redirect slip at the post office

Say you move house but keep your old address on your business cards. You tell the post office: “Send mail for this address to my new one.” The post office follows the slip without caring what your front door looks like.

MX records are that slip. A sending server looks up your domain, finds the MX record, and delivers to the server named there. It never touches your website’s server unless that is also where you receive mail.

What an MX record looks like

Type Name Priority Value
MX @ 1 aspmx.l.google.com
MX @ 5 alt1.aspmx.l.google.com

Each one has:

  • Name: usually @, the bare domain. Mail for you@example.com uses the MX for example.com. (You can set MX for a subdomain too, such as mail.example.com, for separate mail setups.)
  • Priority (or preference): a number. Lower numbers are tried first. If the lowest-numbered server is unavailable, the sender tries the next.
  • Value: the hostname of the mail server. It must be a name, not an IP address. It also must not be a CNAME.

Those two Google records are examples of the style; always copy the exact current values from your provider’s own documentation, since providers change them.

How delivery works, step by step

  1. Someone sends an email to you@example.com.
  2. Their mail server asks DNS: “What are the MX records for example.com?”
  3. DNS returns the list with priorities.
  4. The server connects to the lowest-priority-number host and hands the message over using SMTP, the protocol for sending mail.
  5. If that host doesn’t answer, it tries the next, and keeps retrying for a while if all are unreachable.

I describe the idea of protocols in what a protocol is, with everyday examples, and the wider DNS table in DNS records explained: A, AAAA, CNAME, MX and TXT.

Why you’d change them

  • You started using Google Workspace, Microsoft 365, Zoho or another email service. They give you a set of MX records to add.
  • You switched web hosts and your email was with the old one.
  • You moved DNS to Cloudflare and need to carry the existing mail records across.
  • You want mail to go to a spam filter or forwarding service first.

What goes wrong

Old and new MX records mixed together

If you add Google’s records but leave the old host’s MX records, messages split between two places. Some arrive, some don’t. Remove old ones unless you deliberately want a backup server, and be cautious about backups that don’t have the same mailboxes.

Pointing to an IP address or a CNAME

MX values must be hostnames with their own A/AAAA records. An IP address or an alias isn’t valid, and some servers will bounce mail.

Missing the proxy rule in Cloudflare

If your DNS is on Cloudflare, the record for the mail server hostname must be set to DNS only (grey cloud), not proxied. Cloudflare’s proxy handles web traffic, not mail.

Moving the website and breaking email

You move your website to a new host, and update the A record. That’s fine, but if you also switch nameservers without copying the MX records, the email stops. It’s among the most common migration slips, and I included it in hosting migrations without losing rankings.

Forgetting SPF, DKIM and DMARC

MX records control incoming mail. They don’t prove your outgoing mail is genuine. For that, you publish TXT records:

  • SPF lists the servers allowed to send for your domain.
  • DKIM adds a digital signature.
  • DMARC tells receivers what to do when a message fails.

Gmail and Yahoo announced stricter requirements for bulk senders in 2024, and having these in place is now the sensible baseline for anyone who sends email from their domain at all. This also relates to contact forms; see contact form emails that don’t arrive: fixing deliverability.

How to check your records

  • Use a DNS lookup tool or the dig MX example.com command, which lists the MX records and their priorities.
  • Send a test email from another provider (a personal Gmail account is fine) and make sure it arrives, then reply.
  • Try the reverse too: send from your domain to another provider and check it isn’t in spam.
  • Look for a lookup tool that checks MX, SPF, DKIM and DMARC in one go.

A safe way to change MX records

  1. Create the mailboxes first at the new provider, so there is somewhere for mail to land.
  2. Lower the TTL on the MX records a day or two ahead, so the switch takes effect quickly.
  3. Copy the current records somewhere safe.
  4. Add the new MX records and remove the old ones in one session.
  5. Add or update SPF to include the new provider.
  6. Test both directions.
  7. If you’re moving existing mail, migrate old messages with the provider’s tool or a mail client. Changing MX doesn’t move mail that’s already stored.
  8. Raise the TTL again afterwards.

Do you need email on your own domain at all?

For a business, yes. A professional address builds trust, and you own it. Free webmail addresses are fine for starting out, but they tie your contact details to someone else’s platform. If you only need to receive at first, email forwarding from your domain to a personal inbox is a simple step, and it also uses MX records.

Key takeaways

  • MX records say where email for your domain should be delivered.
  • Lower priority numbers are tried first; values must be hostnames, not IPs or CNAMEs.
  • Mixing old and new records splits your mail.
  • MX controls incoming mail; SPF, DKIM and DMARC help outgoing mail get trusted.
  • Test both sending and receiving after any change.

FAQ

How long until MX changes work?

Often within minutes to a few hours. Servers that remembered the old answer keep using it until the TTL ends.

Can I have multiple mail providers?

Not for the same mailboxes in the normal way. Each domain’s mail goes to the servers in its MX records. Subdomains can be set up differently.

Do I need an MX record if I don’t use email?

If you never want to receive mail on the domain, you can publish a “null MX” to say so, which reduces spam bounces. It’s optional.

Run a lookup on your own domain today. If the MX records belong to a service you stopped paying for, you’ll be glad you looked.