How to Set Up MX Records for Custom Email Domains
mx-recordsemaildnsdomains

How to Set Up MX Records for Custom Email Domains

PPlkdt Labs Editorial
2026-06-09
10 min read

A practical checklist for setting up MX records, avoiding common DNS mistakes, and verifying custom email domain mail flow.

MX records are one of those DNS settings that look simple until email stops flowing. Whether you are launching a new domain, moving inboxes to a different provider, or cleaning up a messy zone file, a careful MX record setup prevents silent delivery failures and saves time later. This guide gives you a reusable checklist for setting up MX records on a custom email domain, plus the related records and verification steps that teams often miss.

Overview

If you need to set up MX records, the core job is straightforward: tell the internet which mail servers are responsible for receiving email for your domain. In practice, a reliable custom email domain DNS setup usually involves more than MX records alone. You also need to confirm the correct hostnames from your mail provider, remove conflicting records, keep priorities in the right order, and add authentication records such as SPF, DKIM, and DMARC.

Think of MX record setup as a short checklist rather than a single DNS edit. The minimal version looks like this:

  • Choose the mail provider that will receive inbound email.
  • Collect the exact MX values from that provider's documentation or admin panel.
  • Add the MX records at the correct DNS host, usually the root domain.
  • Remove old MX records that should no longer receive mail.
  • Add any required TXT or CNAME records for SPF, DKIM, verification, or DMARC.
  • Wait for DNS propagation, then test delivery from an external mailbox.

It also helps to separate DNS responsibilities from mailbox responsibilities. DNS decides where mail for your domain should be delivered. Your mail provider decides what happens after it arrives. If MX is correct but the mailbox does not exist, delivery can still fail. If the mailbox exists but DNS points elsewhere, mail may never reach the right service.

For teams managing domains regularly, write down three things before touching DNS:

  1. Who hosts DNS for the domain right now.
  2. Which provider should receive new inbound mail after the change.
  3. Whether there is a cutover window where both old and new systems are active.

If you are also moving website hosting or nameservers at the same time, separate those changes if possible. Email problems are much easier to isolate when MX changes are not bundled with unrelated DNS edits. If you need a refresher on zone basics, see How to Point a Domain to a Server: A Record, CNAME, Nameservers, and TTL Explained.

Checklist by scenario

Use the scenario that matches your current task. The goal here is to give you a practical order of operations you can revisit each time.

Scenario 1: Setting up email on a brand-new domain

This is the cleanest case because there are usually no legacy records to untangle.

  1. Open your DNS zone. Confirm that you are editing DNS at the active provider, not at a registrar panel that is no longer authoritative.
  2. Collect the required MX records. Your email provider should give you one or more mail server hostnames and priority numbers.
  3. Add the MX records at the right host. For most full-domain mail setups, the host is @ or left blank depending on the DNS UI.
  4. Set a reasonable TTL. If you are in an active rollout, use a shorter TTL for flexibility. You can raise it later.
  5. Add provider verification records. Many providers require a TXT or CNAME record to prove domain ownership.
  6. Add SPF. This is usually a TXT record at the root domain that defines which systems may send mail for the domain.
  7. Add DKIM. This may be a TXT or CNAME record depending on the provider. DKIM supports message signing.
  8. Add DMARC. Even a basic monitoring policy is better than leaving it absent. Use a TXT record at _dmarc.
  9. Test from outside your organization. Send mail from a different provider and confirm that it arrives.

This is also a good time to document the final DNS entries in version control or infrastructure notes. If you manage zones as code, the follow-up step is to capture the records in Terraform or your preferred automation flow. For that workflow, see Terraform DNS Records Guide: Manage Cloudflare and Route 53 as Code.

Scenario 2: Migrating from one email provider to another

This is where most mail server DNS records become confusing, because old records often remain in place after the migration.

  1. Inventory the current state. Export or copy all existing MX, SPF, DKIM, DMARC, autodiscover, and verification records.
  2. Check mailbox readiness on the new provider. DNS should not be changed until the destination mailboxes or aliases exist.
  3. Lower TTL in advance if possible. Make this change before the cutover window, not at the last minute.
  4. Add the new provider's verification and authentication records first. This reduces friction after MX is switched.
  5. Replace old MX records with the new set. Do not mix providers unless you have a deliberate split-delivery plan.
  6. Review SPF carefully. If both providers may send mail during a transition, the SPF policy may need to include both temporarily.
  7. Keep DKIM selectors organized. Different providers often use different selector names. Do not delete an old DKIM record until you know outbound mail no longer relies on it.
  8. Monitor inbound and outbound mail. Test replies, forwarding, internal routing, and messages from consumer mailboxes.
  9. Remove obsolete records after the transition. Old MX, old verification tokens, and stale autodiscover entries can confuse future troubleshooting.

If your team tends to make DNS changes manually under pressure, consider moving recurring changes into a scripted process. That reduces the chance of leaving stale records behind and fits well with a broader dns automation approach.

Scenario 3: Troubleshooting mail that is not arriving

If users say mail is missing, work from DNS outward instead of guessing.

  1. Query the live MX records. Use dig, nslookup, or an online dns propagation check tool to see what resolvers return.
  2. Confirm the domain points to the intended mail provider. The returned MX hostnames should match your provider's current documentation.
  3. Check for multiple MX records with unintended priorities. Lower numbers are preferred. A stale record with a better priority can hijack mail flow.
  4. Verify the host field. A common mistake is placing MX on mail.example.com when the intent was example.com.
  5. Look for missing trailing details in the DNS UI. Some providers auto-append the zone name; others expect a fully qualified domain name. An extra domain suffix creates broken targets.
  6. Inspect nameserver authority. If edits were made in the wrong control panel, public DNS may still serve the old records.
  7. Test with external senders. Try a message from a different provider and note bounce codes or delivery delays.
  8. Review related TXT and CNAME records. Mail delivery can work while authentication fails, which may cause spam placement rather than obvious bounces.

When DNS itself appears broken, broader troubleshooting articles can help narrow the issue. See How to Fix DNS_PROBE_FINISHED_NXDOMAIN for Websites, APIs, and Local Development for authority and resolution checks that also apply to mail-related hostnames.

Scenario 4: Running self-hosted email or a custom mail gateway

Self-hosted email is possible, but it raises the bar for DNS accuracy and deliverability hygiene.

  1. Create stable hostnames for the mail servers. Your MX records should point to real mail hostnames, not IP addresses.
  2. Ensure the mail hostnames resolve with A or AAAA records. MX targets must map to reachable hosts.
  3. Use redundant MX targets if you operate multiple inbound servers. Priorities should reflect intended failover order.
  4. Publish SPF for outbound systems. Include only the hosts or networks that actually send.
  5. Enable DKIM signing and publish the matching DNS records.
  6. Publish DMARC and monitor reports.
  7. Coordinate reverse DNS with the outbound IP owner. This is often controlled at the hosting provider level, not in your public zone.
  8. Test from several external mailbox providers. Self-hosted mail can pass DNS checks and still be treated cautiously by receivers.

If your mail gateway sits behind a broader server setup, good infrastructure hygiene matters too. Related deployment patterns are covered in Nginx Reverse Proxy Setup Guide for Node.js, Docker, and SSL and Docker Deployment Tutorial for Small Production Apps, though mail transport itself should be planned separately from web serving.

What to double-check

Before you call the job done, verify the details that cause the most avoidable failures.

  • Correct host: For whole-domain email, the MX host is usually @. Subdomain mail routing is possible, but make sure that is intentional.
  • Correct target values: MX targets should be hostnames supplied by the mail provider, not IP addresses.
  • Priority order: Lower number means higher priority. If the provider lists multiple MX targets, preserve the order exactly.
  • No leftover legacy MX records: Old entries can still receive mail if their priority is better or equal.
  • Provider-specific formatting: Some DNS panels expect mail.provider.com; others may interpret relative names differently. Always confirm how the UI handles trailing domain names.
  • TTL and propagation expectations: Recent changes may not appear everywhere immediately. Plan validation around this reality.
  • SPF syntax: SPF records must be a single valid TXT policy for the domain. Splitting logic across multiple SPF TXT records often causes problems.
  • DKIM selector names: The selector and host must match exactly.
  • DMARC hostname: The record belongs at _dmarc.example.com, not at the root unless your provider explicitly says otherwise.
  • Nameserver authority: If a registrar and a DNS provider both offer DNS editing, only the authoritative one matters.

A lightweight verification workflow looks like this:

  1. Query MX for the domain.
  2. Query A or AAAA for each MX target if you run your own mail hosts.
  3. Query TXT for SPF and DMARC.
  4. Query the DKIM hostnames provided by your mail vendor.
  5. Send a test email from an external mailbox.
  6. Reply to that email to confirm outbound signing and routing.

If your team manages many domains, this is a good candidate for automation. A simple script can compare expected MX and TXT values against live DNS and flag drift before it becomes a support issue. If you are choosing where to centralize this workflow, Best DNS Providers for Developers: Cloudflare vs Route 53 vs Namecheap vs Others is a useful starting point.

Common mistakes

Most MX issues come from a small set of repeated mistakes. Knowing them upfront saves a surprising amount of time.

Adding MX records in the wrong place

The most common failure is editing the wrong DNS provider. This happens after nameserver moves, registrar transfers, or partially completed migrations. Always confirm the authoritative nameservers before making changes.

Leaving old MX records behind

Mail migrations often fail silently because old MX records remain in the zone. If those records still point to a valid provider, some mail may continue to land there, especially if priorities are misordered.

Pointing MX to an IP address

MX records should point to hostnames, not directly to IPs. The mail hostnames then resolve through A or AAAA records.

Breaking FQDN formatting in the DNS panel

DNS dashboards vary. One panel may expect mx1.provider.net; another may treat that as relative and turn it into mx1.provider.net.example.com. Review the saved record after creation.

Inbound mail may work with MX alone, but modern email dns configuration usually also needs SPF, DKIM, and DMARC. Without them, deliverability and trust can suffer even when routing is technically correct.

Changing multiple systems at once

If you switch nameservers, website hosting, and mail routing in one maintenance window, troubleshooting gets harder fast. Staggering changes makes failures easier to isolate.

Assuming propagation is instant

Some resolvers refresh quickly, others hold older answers longer. Do not treat one successful lookup as proof that every sender now sees the new route.

Not documenting the final state

A working mail setup still becomes future technical debt if nobody knows why the records exist. Keep a short note with the provider, date, purpose, and any temporary transition records that should later be removed.

When to revisit

MX record setup is not a one-time task. Revisit it whenever the inputs change, and use this section as your action list before making edits.

Review your mail DNS when:

  • You migrate to a new email provider.
  • You change DNS providers or nameservers.
  • You add a new outbound sending system, help desk, or transactional email tool.
  • You start seeing bounces, spam-folder placement, or reports of missing mail.
  • You decommission an old provider or server.
  • You adopt infrastructure as code and want DNS consistency across environments.
  • You conduct periodic domain audits before major planning cycles.

Practical maintenance routine:

  1. Export the current zone or capture screenshots before edits.
  2. Compare live MX, SPF, DKIM, and DMARC records against the intended provider setup.
  3. Remove stale records that belong to retired systems.
  4. Test inbound and outbound mail from an external account.
  5. Record the final expected state in a runbook or repository.
  6. Schedule a lightweight review after any provider or workflow change.

If your organization changes DNS frequently, treat email records like application config: version them, review them, and validate them automatically where possible. That mindset turns a fragile manual task into a repeatable operational checklist.

For adjacent workflows, Plkdt also covers DNS providers, infrastructure-as-code patterns, and deployment troubleshooting. Useful follow-ups include Terraform DNS Records Guide and GitHub Actions Deployment Guide: Build, Test, and Deploy Web Apps Reliably if you want to fold DNS checks into a broader ops workflow.

The short version: when you set up MX records, do not stop at the MX values themselves. Verify authority, keep priorities clean, add the supporting authentication records, and document the final state. That small amount of discipline prevents a large amount of email troubleshooting later.

Related Topics

#mx-records#email#dns#domains
P

Plkdt Labs Editorial

Editorial Team

Senior editor and content strategist. Writing about technology, design, and the future of digital media. Follow along for deep dives into the industry's moving parts.