How can I bulk check and clean MX records for a list of domains?

Summary

Bulk checking and cleaning MX records for a list of domains can be achieved through various methods. Command-line tools like `dig` and `nslookup` are frequently recommended, with `dig` being noted for its scripting capabilities for automation. MXToolbox SuperTool and similar online tools offer MX record lookups, with some providing paid API access for bulk checks. SQL scripts, along with database extensions, are useful for categorizing and cleaning records, especially identifying dotMX, null MX, and hosted domains. Validating MX records includes checking for syntax errors like trailing dots and ensuring correct IP addresses. Proper MX record configuration is vital for email deliverability; in the absence of MX records, RFC guidelines suggest falling back to the A record. Cleaning typically involves removing invalid, outdated, or misconfigured records via the domain's DNS settings. Maintaining accurate MX records and performing checks after DNS changes are crucial for email delivery reliability.

Key findings

  • Command-Line Utilities: `dig` and `nslookup` are widely used, scriptable for automated bulk checking.
  • Online Tools: MXToolbox and other tools offer MX record lookups, some with API access for bulk operations.
  • SQL & Database Methods: SQL scripts and database extensions facilitate categorization and cleaning of MX records.
  • Syntax Validation: Correct syntax (no trailing dots) and accurate IP addresses are crucial.
  • MX Record Importance: Valid MX records are essential for email deliverability; use A record fallback if absent.

Key considerations

  • Scripting Skills: Effective use of command-line tools often requires scripting skills for automation.
  • API Costs: Paid APIs are potentially needed for bulk operations with online tools.
  • DNS Access: Admin access to domain's DNS settings is needed to clean up MX records.
  • Validation Accuracy: Routinely validate MX records, especially after DNS changes.
  • Null MX Handling: Consider addressing null MX records and their implications for mail delivery.

What email marketers say
11Marketer opinions

To bulk check and clean MX records, various methods can be employed. Command-line tools like `dig` and `nslookup` are popular, often used in scripts to automate checks for multiple domains. Online tools such as MXToolbox also offer bulk checking capabilities, sometimes via paid APIs. Cleaning involves identifying and removing invalid, outdated, or misconfigured MX records through the domain's DNS settings. Valid MX records are crucial for proper email routing and deliverability. When no MX record is available, senders should fall back to the A record. Checking for common errors like trailing dots or incorrect IP addresses is also important during validation.

Key opinions

  • Command-Line Tools: `dig` and `nslookup` are commonly used for checking MX records, often scripted for bulk operations.
  • Online Tools: MXToolbox and other online tools provide MX record lookup services, some with API access for bulk checking.
  • Cleaning Process: Cleaning involves identifying and removing invalid, outdated, or misconfigured MX records via DNS settings.
  • Importance of MX Records: Valid MX records are essential for correct email routing and deliverability.
  • Fallback Mechanism: In the absence of an MX record, senders should attempt delivery using the A record.

Key considerations

  • Scripting Knowledge: Using command-line tools effectively often requires scripting knowledge for automation.
  • API Costs: Bulk checking via online tool APIs may incur costs, especially for large lists of domains.
  • DNS Access: Cleaning MX records requires access to the domain's DNS settings.
  • Syntax Validation: Validate syntax, IP addresses, and hostnames.
  • Accuracy of Records: Periodically review MX records.
Marketer view

Email marketer from StackOverflow shares how to use the `dig` command in a bash loop to check MX records for multiple domains listed in a file. Suggests the command `for i in $(cat domains.txt); do dig mx $i; done`.

May 2024 - StackOverflow
Marketer view

Email marketer from MXToolbox Support explains that MXToolbox SuperTool can perform MX record lookups for a domain. Suggests that for bulk checking, users can use their API with a paid plan, which enables scripted and automated MX lookups.

August 2023 - MXToolbox
Marketer view

Email marketer from Blackbaud Community explains the importance of verifying correct MX records to ensure email deliverability, and suggests using online tools to verify the records. Advocates for contacting their support to resolve.

October 2022 - Blackbaud Community
Marketer view

Email marketer from Super User shares that to check the MX records of multiple domains, you can create a text file of the domains, then use `nslookup` in batch mode to query records for each domain. In addition, they recommend using the command prompt `set type=mx` before proceeding.

February 2025 - Super User
Marketer view

Email marketer from Hostinger outlines how to correctly set up a MX record. They explain that there are four key parts to an MX record: Type, Name, Priority, and Value. All of these must be configured correctly for the MX to be valid.

November 2023 - Hostinger
Marketer view

Email marketer from EmailAnalytics shares that MX records show how email messages should be routed. To find a domain's MX record using a command line on Windows or Mac, you'll use the command `nslookup` and `set type=mx` then enter the domain.

July 2023 - EmailAnalytics
Marketer view

Email marketer from DigitalOcean Community provides a tutorial on setting up and verifying MX records. Recommends using `dig` or `nslookup` to query the records and comparing the results with the expected values.

November 2024 - DigitalOcean
Marketer view

Email marketer from Reddit recommends using online tools like MXToolbox or using command-line tools such as `nslookup` or `dig` for manual checks. For cleaning, suggests identifying invalid or outdated records and removing them via the domain's DNS settings.

May 2021 - Reddit
Marketer view

Marketer from Email Geeks explains how to use the dig command with a file input (`dig -f domains.txt`) to check MX records and redirect the output to a file, and explains that Matt V's solution is useful because it provides context.

July 2022 - Email Geeks
Marketer view

Marketer from Email Geeks shares that the `dig` command is the quickest and easiest way to check MX records, and provides the command `dig domain MX +short`. Mentions it can be scripted for bulk checking.

August 2024 - Email Geeks
Marketer view

Marketer from Email Geeks explains that an MX record is technically not required to receive email, and if there's no MX record, the sender should fall back to the A record. Also suggests checking for null MX records.

July 2023 - Email Geeks

What the experts say
5Expert opinions

Bulk checking and cleaning MX records involves several methods highlighted by experts. Command-line solutions like `dig` can be used with a file input to test multiple domains, generating a CSV output. SQL scripts can categorize domains that don't accept mail based on dotMX, null MX, or hosted domains. Validation should include checking for syntax errors like trailing dots and incorrect IP addresses. Correct MX records are crucial for email delivery, and incorrect records can lead to bounces or lost emails. DNS lookup tools can verify MX records.

Key opinions

  • Database Extensions: Database extensions can perform MX lookups, recording various domain types.
  • Command-Line Solutions: `dig` with file input can test multiple MX records and generate a CSV output.
  • SQL Scripting: SQL scripts can categorize non-accepting mail domains.
  • Syntax Validation: Validate MX records for correct syntax and IP addresses.
  • Crucial for Delivery: Correct MX records are essential for proper email delivery.

Key considerations

  • Custom Tooling: Database extensions may require custom development.
  • Command-Line Proficiency: Using `dig` effectively requires command-line familiarity.
  • SQL Knowledge: SQL scripting requires knowledge of SQL.
  • Record Accuracy: Ensure the records checked are valid and configured correctly.
  • Regular Checks: Perform periodic checks of MX records, especially after DNS changes.
Expert view

Expert from Email Geeks mentions having a database extension that performs MX lookups on a list of domains, recording MX records, NX domains, and domains that host parked domains.

November 2024 - Email Geeks
Expert view

Expert from Email Geeks shares how they use SQL scripts to clean up MX records, categorizing domains that don't accept mail into dotmx, null MX, and MX for hosted domains.

March 2022 - Email Geeks
Expert view

Expert from Word to the Wise emphasizes the necessity of having valid MX records for email delivery. The staff explains that an incorrect MX record can lead to emails bouncing or being lost. Suggests using DNS lookup tools to verify the MX records are pointing to the correct mail servers. Recommends doing a check whenever making changes to DNS records.

November 2022 - Word to the Wise
Expert view

Expert from Email Geeks provides a command line solution for testing MX records in bulk using `dig mx -f .\filename.txt >> outputfile.csv +noall +answer +cmd`, which generates a CSV file with the data. The input `filename.txt` is a list of domains to test.

January 2023 - Email Geeks
Expert view

Expert from Spam Resource explains that when validating MX records, it's important to also check for common mistakes such as having trailing dots, incorrect IP addresses, or misconfigured hostnames. It provides tips for correctly checking syntax.

November 2024 - Spam Resource

What the documentation says
4Technical articles

Documentation highlights various methods for checking MX records. Google's Dig tool in the Admin Toolbox provides detailed record information but requires manual input. The `dig` command, as detailed by ISC, offers options for specifying query types and output formats, with `+short` for cleaner output. `Nslookup` also allows querying of MX records via the command line by specifying 'set type=mx'. When no MX records are found, RFC specifications dictate falling back to the A record for delivery.

Key findings

  • Google's Dig Tool: Provides detailed MX record information but requires manual input.
  • dig Command: Offers flexible querying options, with `+short` for cleaner output.
  • nslookup Tool: Allows querying MX records from the command line by setting the type to MX.
  • Fallback to A Record: If no MX record is present, delivery should fall back to the A record.

Key considerations

  • Manual Input: Google's Dig tool requires manual input, making it less suitable for bulk checking.
  • Command-Line Knowledge: Using `dig` and `nslookup` effectively requires familiarity with command-line interfaces.
  • Output Parsing: Parsing the output of `dig` and `nslookup` may require scripting for automated analysis.
  • RFC Compliance: Adherence to RFC specifications is important for proper email delivery.
Technical article

Documentation from Google explains the use of their Dig tool in the Admin Toolbox to query DNS records including MX records. It requires manual input of each domain but provides detailed record information.

November 2022 - Google
Technical article

Documentation from Nslookup explains how to use the command-line tool nslookup to query DNS records including MX records. Specifies that entering `set type=mx` before entering the domain name will allow the user to see what the MX records are for that domain.

May 2022 - Network Tools
Technical article

Documentation from ISC provides detailed information on using the `dig` command for querying DNS records, including MX records. Explains the various options and flags available for specifying query types and output formats. Specifically highlights the +short option for cleaner output.

December 2024 - ISC
Technical article

Documentation from RFC Editor explains how to deliver emails when no MX records are found, specifying to fall back to the A record for the domain. It also notes the process of resolving issues.

October 2021 - RFC Editor