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 Linting: ruff 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) from a folder or file into readable tables or CSVs.
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

Analyze reports in your current directory, a specific folder, or even a single file.

# Display all records in current directory
mailops report

# Analyze reports in a specific folder
mailops report ./my_logs/

# Analyze a single XML file
mailops report report.xml

# Export all records to CSV
mailops report --csv dmarc_analysis.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 and lint code with Ruff (fast & unified)
ruff format .
ruff check --fix .

๐Ÿค Contributing

We want to keep this lightweight and portable.

  • Standard Libs First: Trying to avoid external dependencies to ensure the tool runs anywhere.
  • Code Style: UsingRuff for high-performance, unified linting and formatting.
  • 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.5.2.tar.gz (13.6 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.5.2-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for mail_ops_scripts-2.5.2.tar.gz
Algorithm Hash digest
SHA256 f1143b76a74dfe45ff9e79c99d6eb2e9f975652e66b6998ca86309cb80eb0c48
MD5 86266b8afd2f0a1c903699b2a4002eb0
BLAKE2b-256 1d86cc2180648f31e3443f4f80380bd491382e49d873476aff17baf0b1b64677

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mail_ops_scripts-2.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0d73e02ec4bb1bb0af39442217accf36e998cff1addf0f2496724ff828c35292
MD5 076062633ac9f6782b2cf583d609244f
BLAKE2b-256 05d51dfbc3bfeb8507d376dae205693012157d570980688d3091dc0a048a5e3e

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