Skip to main content

A unified operational toolkit for email server administration and DMARC analysis.

Project description

mail ops scripts project logo

Mail Ops Scripts

PyPI Version CI Code style: black Imports: isort Python 3.8+ License: MIT

A unified operational toolkit for email server administration, security analysis, and reporting.

๐Ÿš€ Now available on PyPI!

You can now install mailops globally with a single command.


โšก Quick Start

Get the CLI installed directly from PyPI and start managing your mail operations in seconds.

# Install via pip
pip install mail-ops-scripts

# Verify installation
mailops --help

๐Ÿ›  The Toolkit

mailops is a single binary aimed at simplifying the fragmented world of email admin. No more juggling random bash scripts or online DNS checkers.

Command Description
mailops fetch Connects to Gmail/Exchange via IMAP to download DMARC reports.
mailops report Parses XML reports (.xml, .gz, .zip) into readable tables or CSVs with alerts.
mailops spf Validates SPF records using Google's DNS-over-HTTPS (secure & cached).
mailops dkim Generates 2048-bit RSA keys and formats the exact DNS TXT record you need.

๐Ÿš€ Common Workflows

1. The "Monday Morning" Check

Grab the last week's DMARC reports from your dedicated inbox and see if anyone is spoofing you.

# 1. Download reports from your dmarc@ account
mailops fetch --user admin@example.com --password "app-password" --days 7

# 2. Analyze the data (view alerts only)
mailops report --alerts

2. Setting Up a New Domain

Spinning up a new sender? Generate your security keys and validate your DNS instantly.

# 1. Generate DKIM keys (outputs to ./default.private)
mailops dkim example.com --selector=mail

# 2. Verify your SPF record is live and valid
mailops spf example.com

3. Generate DMARC Analysis Report

Export your DMARC data to CSV for security team review or further analysis.

# Display all records in formatted table
mailops report

# Export all records to CSV
mailops report --csv dmarc_analysis.csv

# Export only authentication failures to CSV
mailops report --alerts --csv security_alerts.csv

๐Ÿ“Š Report Command Features

The mailops report command analyzes DMARC XML reports and provides:

  • Formatted Tables: Color-coded analysis of SPF, DKIM, and DMARC policy results
  • Alert Filtering: --alerts flag to show only authentication failures and spoofing attempts
  • CSV Export: --csv flag to save results for further analysis
  • Compressed Format Support: Automatically handles .xml, .xml.gz, and .zip files
  • Organized Output: Groups results by organization and date range

Report Output Example

$ mailops report
๐Ÿ“Š Analyzing REAL DMARC reports...
Found 5 XML files:
  ๐Ÿ“„ enterprise.protection.outlook.com!example.com!1765324800!1765411200.xml.gz
  ...

Report: enterprise.protection.outlook.com (2025-12-01)
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
Source IP           | Hostname                   | Cnt | SPF  | DKIM | Analysis
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
192.168.1.1         | mail.example.com           | 42  | pass | pass | OK
10.0.0.5            | suspicious.domain          | 3   | fail | fail | INVESTIGATE

๐Ÿ“ฆ Developer Setup

If you want to contribute or modify the scripts, here is how to get the dev environment running locally.

# Clone and setup
git clone https://github.com/knowoneactual/mail-ops-scripts
cd mail-ops-scripts

# Create virtual env
python -m venv .venv
source .venv/bin/activate

# Install in editable mode with dev dependencies
pip install -e '.[dev]'

# Run the test suite
pytest

# Format code with black
black mailops/

# Sort imports with isort
isort mailops/

๐Ÿค Contributing

We want to keep this lightweight and portable.

  • Standard Libs First: We try to avoid external dependencies to ensure the tool runs anywhere.
  • Code Style: We use black and isort.
  • See details: Check CONTRIBUTING.md for the full guide.

๐Ÿ“„ License

MIT ยฉ KnowOneActual


Made with โค๏ธ for email operations

๐Ÿ—บ๏ธ Roadmap

Project Board

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mail_ops_scripts-2.4.0.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mail_ops_scripts-2.4.0-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file mail_ops_scripts-2.4.0.tar.gz.

File metadata

  • Download URL: mail_ops_scripts-2.4.0.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for mail_ops_scripts-2.4.0.tar.gz
Algorithm Hash digest
SHA256 02250cef18d822349754be7bfb36d18ece5fa748f073298ef72be4f146dd99bc
MD5 4fc3dcb6525db72f18fe7bb063dbe43f
BLAKE2b-256 7f7a46fb1be28905d5bd2699375a26eb13473066ff9631f8ec530990c8542853

See more details on using hashes here.

File details

Details for the file mail_ops_scripts-2.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mail_ops_scripts-2.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 44831f95b14c1fff1c15b586a4b82285663ee24d77ff4e9ad15a629fb121ce9d
MD5 3294272bac537f70048e78de8a16f1d2
BLAKE2b-256 5b96a3dd88d2f4aeedd77b4d823a4ae62a6cd28e0fc70e469c1999d9d010c742

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page