MX-Report is a Python script designed to analyze a domain's email health by inspecting its MX, SPF, DMARC, and DKIM related DNS records. It provides a comprehensive report in text, JSON, or HTML format, helping to identify potential issues with email deliverability and security.
- MX Record Analysis: Fetches MX records and attempts to identify the email provider (e.g., Google Workspace, Microsoft 365).
- SPF Record Validation:
- Retrieves and parses the SPF TXT record.
- Breaks down each mechanism and modifier, providing explanations.
- Checks for common issues like multiple SPF records or overly permissive
allmechanisms. - Performs reverse DNS lookups for IP addresses found in
ip4andip6mechanisms.
- DMARC Record Check:
- Retrieves and parses the DMARC record (
_dmarc.<domain>). - Analyzes the DMARC policy (
p=), reporting URIs (rua,ruf), and other tags.
- Retrieves and parses the DMARC record (
- DKIM Record Check:
- Attempts to find DKIM records for commonly used selectors (e.g.,
selector1,google). - Allows users to specify custom DKIM selectors for checking.
- Attempts to find DKIM records for commonly used selectors (e.g.,
- Comprehensive Health Report:
- Summarizes findings with warnings and recommendations.
- Provides an overall health status (GOOD, FAIR, NEEDS ATTENTION).
- Multiple Output Formats: Supports plain text, JSON, and HTML output for easy consumption or integration.
- Python 3.x
- The
dnspythonlibrary
- Clone the repository or download the
mx-report.pyscript. - Install the required
dnspythonlibrary:pip install dnspython
The script is run from the command line, with the domain to analyze as a required argument.
python mx-report.py <domain> [options]domain: (Required) The domain name you want to analyze (e.g.,example.com).
--dkim-selectors SELECTOR [SELECTOR ...]: (Optional) A list of specific DKIM selectors to check (e.g.,google selector1 k1). If not provided, a list of common selectors will be checked.--format {text,json,html}: (Optional) The output format for the report. Defaults totext.text: Plain text output, suitable for console viewing.json: JSON formatted output, suitable for programmatic use or integration with other tools.html: HTML formatted report, suitable for viewing in a web browser.
-
Analyze a domain with default text output:
python mx-report.py example.com
-
Analyze a domain and specify custom DKIM selectors:
python mx-report.py example.com --dkim-selectors s1 s2 mailjet
-
Get the report in JSON format:
python mx-report.py example.com --format json
To save to a file:
python mx-report.py example.com --format json > report.json -
Get the report in HTML format:
python mx-report.py example.com --format html
To save to a file and open in a browser:
python mx-report.py example.com --format html > report.html # Then open report.html in your web browser
This project is licensed under the MIT License - see the LICENSE file for details.
Created with ❤️ by Jon Arnar Jonsson.