How can I bulk check and clean MX records for a list of domains?
Matthew Whittaker
Co-founder & CTO, Suped
Published 10 Jul 2025
Updated 16 Aug 2025
7 min read
Maintaining a healthy email list is crucial for successful deliverability. Before sending out campaigns, I always advise cleaning your list to remove invalid or problematic email addresses. One key step in this process involves checking and cleaning MX records for your list of domains.
MX records, or Mail Exchanger records, are a type of DNS record that specifies which mail servers are responsible for accepting email messages on behalf of a domain name. If a domain doesn't have a valid MX record, emails sent to that domain are likely to bounce, negatively impacting your sender reputation. For anyone managing large email lists, doing this verification manually is impractical.
This guide will walk you through how I approach bulk checking MX records and what steps I take to clean a domain list based on these findings. The goal is to identify and remove problematic domains before they affect your email deliverability or incur costs from external email validation services.
The role of MX records in email deliverability
MX records are fundamental to how email is routed across the internet. When an email server wants to send an email to example.com, it first queries the domain's DNS to find its MX records. These records point to the mail servers designated to receive mail for that domain, along with a preference value (priority) indicating which server to try first.
A valid MX record ensures that incoming emails have a proper destination. Without one, email delivery becomes impossible or highly unreliable, often leading to bounces. This directly impacts your sender reputation, as a high bounce rate signals to mailbox providers that you might be sending to invalid or unengaged addresses. This can cause you to land on a spam blacklist (or blocklist).
While an MX record is standard, some domains might not have one and still technically be able to receive mail if an A record exists for the domain's root. However, this is uncommon for legitimate email infrastructure and can be a sign of a misconfigured or defunct domain. It's often a red flag when I encounter it, as these domains are rarely active for consistent email communication.
Invalid: No MX records, meaning no email server is configured to receive mail for that domain.
Defunct: The domain might no longer be active or used for email communication.
Spam traps: Some domains (or addresses within them) are set up specifically to catch senders who don't clean their lists. Identifying non-existent MX records can help avoid these.
Approaches to bulk MX record lookup
For a small number of domains, manually checking MX records using tools like dig or nslookup on the command line is feasible. However, when dealing with lists of hundreds or thousands of domains, a bulk approach is essential. Manual checks are time-consuming and prone to human error, making them impractical for serious list hygiene.
Manual lookup
Using command-line tools like dig domain MX or online MX lookup tools.
Speed: Very slow for large lists. Each domain must be checked individually.
Accuracy: Reliant on careful manual input and transcription.
Scalability: Not scalable for hundreds or thousands of domains.
Programmatic/bulk lookup
Scripting dig, nslookup, or Resolve-DnsName (PowerShell) to process a file of domains.
Speed: Fast, capable of checking thousands of domains in minutes.
Accuracy: Automated and consistent, reducing human error.
Scalability: Easily handles large lists, ideal for ongoing list hygiene.
For bulk checks, command-line tools such as dig (available on Linux/macOS and now Windows) are highly effective. They allow you to feed a list of domains from a file and output the results to another file, which you can then parse and analyze. This process significantly streamlines the identification of invalid or suspicious MX records in your database. Alternatively, PowerShell offers similar capabilities on Windows, as detailed in this guide.
Before you begin, prepare a simple text file, for example, domains.txt, with one domain per line. Ensure there are no extra characters or URLs, just the clean domain names. This file will be the input for your bulk lookup.
This dig command is straightforward: dig mx specifies that you want to query MX records. -f .\domains.txt tells dig to read domains from your domains.txt file. >> output.csv appends the output to a CSV file. +noall +answer +cmd filters the output to show only the answers, making it easier to parse later. The +cmd option is particularly useful as it provides context, showing which domain the query was run for.
Once the command completes, open your output.csv file. You will see entries for each domain, similar to the examples from Google, Microsoft, and Yahoo. Each line will typically include the domain, TTL, IN, MX, priority, and the MX server hostname.
Understanding null MX records
While most domains without an MX record are simply unconfigured, some might explicitly state they do not accept email by having a null MX record. This is indicated by an MX record pointing to a single dot (.) with a priority of 0. For example: example.com. 3600 IN MX 0 .. This is defined in RFC 7505. While not widely used, it explicitly signals that a domain should not receive email and should be removed from your lists.
Cleaning your domain list based on MX records
After you've performed the bulk lookup, the next critical step is to analyze the output.csv file and clean your domain list accordingly. The goal is to filter out domains that are undeliverable, misconfigured, or potentially harmful, such as spam traps. This proactive cleaning reduces bounces and protects your sender reputation.
You can use scripting languages (like Python, Perl, or Bash) or spreadsheet software to process the output.csv. Look for patterns indicating an issue: no MX records returned, a null MX record (priority 0 pointing to .), or MX records pointing to known parked domain services. Filtering and sanitizing your email domains based on these criteria significantly improves your deliverability.
MX record status
Description
Recommended action
Valid MX records present
One or more MX records pointing to active mail servers (e.g., Google, Outlook).
Keep the domain, likely valid for email delivery. Proceed with further email verification.
No MX records found (NXDOMAIN)
The domain either does not exist or has no mail servers configured.
Remove the domain from your list. Sending to these will result in hard bounces.
Null MX record
An MX record set to "0 ." indicating the domain explicitly refuses email.
Remove the domain. This signals non-acceptance of email.
MX record for parked domain
MX records point to servers associated with domain parking services, not active email accounts.
Remove the domain. These domains are unlikely to have valid email recipients. You may also want to check against bad domain lists.
MX record pointing to an A record
A domain with no explicit MX record, relying on a root A record for mail delivery (rare for legitimate senders).
Investigate further. Consider removing if no active mail service is confirmed. These domains are often abandoned.
By systematically categorizing and cleaning your domain list, you're not just reducing bounce rates, you're actively improving your email deliverability and ensuring your messages reach engaged recipients. This step is a powerful precursor to any further email verification or campaign sends, saving you time and resources in the long run. Learn more about categorizing MX records.
Views from the trenches
Best practices
Always keep a backup of your original domain list before performing any cleaning operations. This allows for recovery if an error occurs during the cleaning process.
Combine MX record checks with other validation methods for comprehensive list hygiene, such as checking for syntax errors, common typos, and temporary email addresses.
Regularly repeat this MX record checking process, especially for older or unengaged segments of your email list, as domain statuses can change over time.
Segment your list based on MX record findings, e.g., 'valid for mail,' 'no MX,' 'parked,' for more targeted re-engagement or removal strategies.
Automate the MX lookup and initial filtering as part of your data ingestion pipeline to proactively prevent problematic domains from entering your active mailing lists.
Common pitfalls
Forgetting that some legitimate domains might not have MX records (falling back to A records) and mistakenly removing them, although this is rare for active email communication.
Not accounting for rate limits or DNS query limits from your DNS provider if you're running extremely large bulk lookups, which can lead to temporary blocks or incomplete results.
Failing to differentiate between domains with no MX records and domains with a null MX record, as both indicate non-deliverability but for different reasons.
Over-relying solely on MX record checks without further validation, as a domain might have an MX record but the specific email address might still be invalid or a spam trap.
Not cleaning the domain list after identifying issues, which leads to continued sending to problematic addresses and damages sender reputation, potentially leading to an IP address or domain blacklist (blocklist).
Expert tips
Use DNS client libraries in programming languages (e.g., `dnspython` in Python) for more robust and feature-rich bulk MX lookups than simple shell scripts.
Implement a retry mechanism for failed DNS queries, as transient network issues can sometimes lead to temporary lookup failures, causing false negatives.
Prioritize removing domains with no MX or null MX records first, as these are the clearest indicators of undeliverable email, offering the highest immediate deliverability gains.
Develop a system to cross-reference MX records with known hosting providers for parked domains or generic email services to get a more granular understanding of domain activity.
If your organization has strict compliance requirements, consider documenting the methodology and criteria used for MX record cleaning to demonstrate due diligence.
Marketer view
Marketer from Email Geeks says they use 'dig domain MX +short' as the quickest way to check MX records, and it's easily scriptable for bulk processing.
2022-03-11 - Email Geeks
Expert view
Expert from Email Geeks says that if no MX record is found, an email sender should technically fall back to the A record to attempt delivery, though this is not commonly used for active mail.
2022-03-12 - Email Geeks
Final thoughts on list hygiene
Bulk checking and cleaning MX records is a fundamental and often overlooked step in maintaining a healthy and high-performing email list. By identifying domains that cannot receive email, whether due to missing, null, or parked MX records, you significantly reduce bounces and protect your sender reputation. This proactive approach saves resources, improves campaign effectiveness, and minimizes the risk of landing on an email blocklist.
Leveraging command-line tools like dig or scripting solutions allows for efficient processing of even very large domain lists. The output provides actionable insights, enabling you to make informed decisions about which domains to keep and which to remove, thereby ensuring your email efforts are directed at genuinely deliverable addresses. This sets the stage for overall improved email deliverability.
By integrating this process into your routine list management, you'll see a noticeable improvement in your email campaign performance and maintain a healthier sender reputation over time.