mail-ops-scripts 2.2.0__tar.gz → 2.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. mail_ops_scripts-2.4.0/PKG-INFO +179 -0
  2. mail_ops_scripts-2.4.0/README.md +157 -0
  3. mail_ops_scripts-2.4.0/mail_ops_scripts.egg-info/PKG-INFO +179 -0
  4. {mail_ops_scripts-2.2.0 → mail_ops_scripts-2.4.0}/mailops/cli.py +62 -6
  5. {mail_ops_scripts-2.2.0 → mail_ops_scripts-2.4.0}/pyproject.toml +1 -1
  6. {mail_ops_scripts-2.2.0 → mail_ops_scripts-2.4.0}/tests/test_version.py +1 -1
  7. mail_ops_scripts-2.2.0/PKG-INFO +0 -147
  8. mail_ops_scripts-2.2.0/README.md +0 -125
  9. mail_ops_scripts-2.2.0/mail_ops_scripts.egg-info/PKG-INFO +0 -147
  10. {mail_ops_scripts-2.2.0 → mail_ops_scripts-2.4.0}/LICENSE +0 -0
  11. {mail_ops_scripts-2.2.0 → mail_ops_scripts-2.4.0}/mail_ops_scripts.egg-info/SOURCES.txt +0 -0
  12. {mail_ops_scripts-2.2.0 → mail_ops_scripts-2.4.0}/mail_ops_scripts.egg-info/dependency_links.txt +0 -0
  13. {mail_ops_scripts-2.2.0 → mail_ops_scripts-2.4.0}/mail_ops_scripts.egg-info/entry_points.txt +0 -0
  14. {mail_ops_scripts-2.2.0 → mail_ops_scripts-2.4.0}/mail_ops_scripts.egg-info/requires.txt +0 -0
  15. {mail_ops_scripts-2.2.0 → mail_ops_scripts-2.4.0}/mail_ops_scripts.egg-info/top_level.txt +0 -0
  16. {mail_ops_scripts-2.2.0 → mail_ops_scripts-2.4.0}/mailops/__init__.py +0 -0
  17. {mail_ops_scripts-2.2.0 → mail_ops_scripts-2.4.0}/mailops/__main__.py +0 -0
  18. {mail_ops_scripts-2.2.0 → mail_ops_scripts-2.4.0}/mailops/blacklist_monitor.py +0 -0
  19. {mail_ops_scripts-2.2.0 → mail_ops_scripts-2.4.0}/mailops/dkim_gen.py +0 -0
  20. {mail_ops_scripts-2.2.0 → mail_ops_scripts-2.4.0}/mailops/dmarc_parser.py +0 -0
  21. {mail_ops_scripts-2.2.0 → mail_ops_scripts-2.4.0}/mailops/imap_fetcher.py +0 -0
  22. {mail_ops_scripts-2.2.0 → mail_ops_scripts-2.4.0}/mailops/spf_check.py +0 -0
  23. {mail_ops_scripts-2.2.0 → mail_ops_scripts-2.4.0}/mailops/ui.py +0 -0
  24. {mail_ops_scripts-2.2.0 → mail_ops_scripts-2.4.0}/setup.cfg +0 -0
@@ -0,0 +1,179 @@
1
+ Metadata-Version: 2.4
2
+ Name: mail-ops-scripts
3
+ Version: 2.4.0
4
+ Summary: A unified operational toolkit for email server administration and DMARC analysis.
5
+ Author-email: Beau Bremer <beau.bremer@tutamial.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/KnowOneActual/mail-ops-scripts
8
+ Project-URL: Repository, https://github.com/KnowOneActual/mail-ops-scripts
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.8
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Provides-Extra: dev
15
+ Requires-Dist: pytest>=7.0; extra == "dev"
16
+ Requires-Dist: black>=23.0; extra == "dev"
17
+ Requires-Dist: isort>=5.12; extra == "dev"
18
+ Requires-Dist: mypy>=1.5; extra == "dev"
19
+ Requires-Dist: build; extra == "dev"
20
+ Requires-Dist: twine; extra == "dev"
21
+ Dynamic: license-file
22
+
23
+ <div align="center">
24
+ <img src="assets/img/mail-ops-scripts.webp" alt="mail ops scripts project logo" width="200">
25
+
26
+ # Mail Ops Scripts
27
+
28
+ [![PyPI Version](https://img.shields.io/pypi/v/mail-ops-scripts?color=blue&style=flat-square)](https://pypi.org/project/mail-ops-scripts/)
29
+ [![CI](https://github.com/KnowOneActual/mail-ops-scripts/actions/workflows/ci.yml/badge.svg)](https://github.com/KnowOneActual/mail-ops-scripts/actions/workflows/ci.yml)
30
+ [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
31
+ [![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
32
+ [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
33
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
34
+
35
+ **A unified operational toolkit for email server administration, security analysis, and reporting.**
36
+
37
+ ### 🚀 Now available on PyPI!
38
+ You can now install `mailops` globally with a single command.
39
+
40
+ </div>
41
+
42
+ ---
43
+
44
+ ## ⚡ Quick Start
45
+
46
+ Get the CLI installed directly from PyPI and start managing your mail operations in seconds.
47
+
48
+ ```bash
49
+ # Install via pip
50
+ pip install mail-ops-scripts
51
+
52
+ # Verify installation
53
+ mailops --help
54
+ ```
55
+
56
+ ## 🛠 The Toolkit
57
+
58
+ `mailops` is a single binary aimed at simplifying the fragmented world of email admin. No more juggling random bash scripts or online DNS checkers.
59
+
60
+ | Command | Description |
61
+ | :--- | :--- |
62
+ | **`mailops fetch`** | Connects to Gmail/Exchange via IMAP to download DMARC reports. |
63
+ | **`mailops report`** | Parses XML reports (.xml, .gz, .zip) into readable tables or CSVs with alerts. |
64
+ | **`mailops spf`** | Validates SPF records using Google's DNS-over-HTTPS (secure & cached). |
65
+ | **`mailops dkim`** | Generates 2048-bit RSA keys and formats the exact DNS TXT record you need. |
66
+
67
+ ## 🚀 Common Workflows
68
+
69
+ ### 1. The "Monday Morning" Check
70
+
71
+ Grab the last week's DMARC reports from your dedicated inbox and see if anyone is spoofing you.
72
+
73
+ ```bash
74
+ # 1. Download reports from your dmarc@ account
75
+ mailops fetch --user admin@example.com --password "app-password" --days 7
76
+
77
+ # 2. Analyze the data (view alerts only)
78
+ mailops report --alerts
79
+ ```
80
+
81
+ ### 2. Setting Up a New Domain
82
+
83
+ Spinning up a new sender? Generate your security keys and validate your DNS instantly.
84
+
85
+ ```bash
86
+ # 1. Generate DKIM keys (outputs to ./default.private)
87
+ mailops dkim example.com --selector=mail
88
+
89
+ # 2. Verify your SPF record is live and valid
90
+ mailops spf example.com
91
+ ```
92
+
93
+ ### 3. Generate DMARC Analysis Report
94
+
95
+ Export your DMARC data to CSV for security team review or further analysis.
96
+
97
+ ```bash
98
+ # Display all records in formatted table
99
+ mailops report
100
+
101
+ # Export all records to CSV
102
+ mailops report --csv dmarc_analysis.csv
103
+
104
+ # Export only authentication failures to CSV
105
+ mailops report --alerts --csv security_alerts.csv
106
+ ```
107
+
108
+ ## 📊 Report Command Features
109
+
110
+ The `mailops report` command analyzes DMARC XML reports and provides:
111
+
112
+ - **Formatted Tables**: Color-coded analysis of SPF, DKIM, and DMARC policy results
113
+ - **Alert Filtering**: `--alerts` flag to show only authentication failures and spoofing attempts
114
+ - **CSV Export**: `--csv` flag to save results for further analysis
115
+ - **Compressed Format Support**: Automatically handles `.xml`, `.xml.gz`, and `.zip` files
116
+ - **Organized Output**: Groups results by organization and date range
117
+
118
+ ### Report Output Example
119
+
120
+ ```bash
121
+ $ mailops report
122
+ 📊 Analyzing REAL DMARC reports...
123
+ Found 5 XML files:
124
+ 📄 enterprise.protection.outlook.com!example.com!1765324800!1765411200.xml.gz
125
+ ...
126
+
127
+ Report: enterprise.protection.outlook.com (2025-12-01)
128
+ ─────────────────────────────────────────────────────────────────────────
129
+ Source IP | Hostname | Cnt | SPF | DKIM | Analysis
130
+ ─────────────────────────────────────────────────────────────────────────
131
+ 192.168.1.1 | mail.example.com | 42 | pass | pass | OK
132
+ 10.0.0.5 | suspicious.domain | 3 | fail | fail | INVESTIGATE
133
+ ```
134
+
135
+ ## 📦 Developer Setup
136
+
137
+ If you want to contribute or modify the scripts, here is how to get the dev environment running locally.
138
+
139
+ ```bash
140
+ # Clone and setup
141
+ git clone https://github.com/knowoneactual/mail-ops-scripts
142
+ cd mail-ops-scripts
143
+
144
+ # Create virtual env
145
+ python -m venv .venv
146
+ source .venv/bin/activate
147
+
148
+ # Install in editable mode with dev dependencies
149
+ pip install -e '.[dev]'
150
+
151
+ # Run the test suite
152
+ pytest
153
+
154
+ # Format code with black
155
+ black mailops/
156
+
157
+ # Sort imports with isort
158
+ isort mailops/
159
+ ```
160
+
161
+ ## 🤝 Contributing
162
+
163
+ We want to keep this lightweight and portable.
164
+
165
+ * **Standard Libs First**: We try to avoid external dependencies to ensure the tool runs anywhere.
166
+ * **Code Style**: We use `black` and `isort`.
167
+ * **See details**: Check [CONTRIBUTING.md](CONTRIBUTING.md) for the full guide.
168
+
169
+ ## 📄 License
170
+
171
+ MIT © [KnowOneActual](LICENSE)
172
+
173
+ ---
174
+
175
+ **Made with ❤️ for email operations**
176
+
177
+ ## 🗺️ Roadmap
178
+
179
+ [![Project Board](https://github.com/users/KnowOneActual/projects/2/views/1)](https://github.com/users/KnowOneActual/projects/2/views/1)
@@ -0,0 +1,157 @@
1
+ <div align="center">
2
+ <img src="assets/img/mail-ops-scripts.webp" alt="mail ops scripts project logo" width="200">
3
+
4
+ # Mail Ops Scripts
5
+
6
+ [![PyPI Version](https://img.shields.io/pypi/v/mail-ops-scripts?color=blue&style=flat-square)](https://pypi.org/project/mail-ops-scripts/)
7
+ [![CI](https://github.com/KnowOneActual/mail-ops-scripts/actions/workflows/ci.yml/badge.svg)](https://github.com/KnowOneActual/mail-ops-scripts/actions/workflows/ci.yml)
8
+ [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
9
+ [![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
10
+ [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
11
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
12
+
13
+ **A unified operational toolkit for email server administration, security analysis, and reporting.**
14
+
15
+ ### 🚀 Now available on PyPI!
16
+ You can now install `mailops` globally with a single command.
17
+
18
+ </div>
19
+
20
+ ---
21
+
22
+ ## ⚡ Quick Start
23
+
24
+ Get the CLI installed directly from PyPI and start managing your mail operations in seconds.
25
+
26
+ ```bash
27
+ # Install via pip
28
+ pip install mail-ops-scripts
29
+
30
+ # Verify installation
31
+ mailops --help
32
+ ```
33
+
34
+ ## 🛠 The Toolkit
35
+
36
+ `mailops` is a single binary aimed at simplifying the fragmented world of email admin. No more juggling random bash scripts or online DNS checkers.
37
+
38
+ | Command | Description |
39
+ | :--- | :--- |
40
+ | **`mailops fetch`** | Connects to Gmail/Exchange via IMAP to download DMARC reports. |
41
+ | **`mailops report`** | Parses XML reports (.xml, .gz, .zip) into readable tables or CSVs with alerts. |
42
+ | **`mailops spf`** | Validates SPF records using Google's DNS-over-HTTPS (secure & cached). |
43
+ | **`mailops dkim`** | Generates 2048-bit RSA keys and formats the exact DNS TXT record you need. |
44
+
45
+ ## 🚀 Common Workflows
46
+
47
+ ### 1. The "Monday Morning" Check
48
+
49
+ Grab the last week's DMARC reports from your dedicated inbox and see if anyone is spoofing you.
50
+
51
+ ```bash
52
+ # 1. Download reports from your dmarc@ account
53
+ mailops fetch --user admin@example.com --password "app-password" --days 7
54
+
55
+ # 2. Analyze the data (view alerts only)
56
+ mailops report --alerts
57
+ ```
58
+
59
+ ### 2. Setting Up a New Domain
60
+
61
+ Spinning up a new sender? Generate your security keys and validate your DNS instantly.
62
+
63
+ ```bash
64
+ # 1. Generate DKIM keys (outputs to ./default.private)
65
+ mailops dkim example.com --selector=mail
66
+
67
+ # 2. Verify your SPF record is live and valid
68
+ mailops spf example.com
69
+ ```
70
+
71
+ ### 3. Generate DMARC Analysis Report
72
+
73
+ Export your DMARC data to CSV for security team review or further analysis.
74
+
75
+ ```bash
76
+ # Display all records in formatted table
77
+ mailops report
78
+
79
+ # Export all records to CSV
80
+ mailops report --csv dmarc_analysis.csv
81
+
82
+ # Export only authentication failures to CSV
83
+ mailops report --alerts --csv security_alerts.csv
84
+ ```
85
+
86
+ ## 📊 Report Command Features
87
+
88
+ The `mailops report` command analyzes DMARC XML reports and provides:
89
+
90
+ - **Formatted Tables**: Color-coded analysis of SPF, DKIM, and DMARC policy results
91
+ - **Alert Filtering**: `--alerts` flag to show only authentication failures and spoofing attempts
92
+ - **CSV Export**: `--csv` flag to save results for further analysis
93
+ - **Compressed Format Support**: Automatically handles `.xml`, `.xml.gz`, and `.zip` files
94
+ - **Organized Output**: Groups results by organization and date range
95
+
96
+ ### Report Output Example
97
+
98
+ ```bash
99
+ $ mailops report
100
+ 📊 Analyzing REAL DMARC reports...
101
+ Found 5 XML files:
102
+ 📄 enterprise.protection.outlook.com!example.com!1765324800!1765411200.xml.gz
103
+ ...
104
+
105
+ Report: enterprise.protection.outlook.com (2025-12-01)
106
+ ─────────────────────────────────────────────────────────────────────────
107
+ Source IP | Hostname | Cnt | SPF | DKIM | Analysis
108
+ ─────────────────────────────────────────────────────────────────────────
109
+ 192.168.1.1 | mail.example.com | 42 | pass | pass | OK
110
+ 10.0.0.5 | suspicious.domain | 3 | fail | fail | INVESTIGATE
111
+ ```
112
+
113
+ ## 📦 Developer Setup
114
+
115
+ If you want to contribute or modify the scripts, here is how to get the dev environment running locally.
116
+
117
+ ```bash
118
+ # Clone and setup
119
+ git clone https://github.com/knowoneactual/mail-ops-scripts
120
+ cd mail-ops-scripts
121
+
122
+ # Create virtual env
123
+ python -m venv .venv
124
+ source .venv/bin/activate
125
+
126
+ # Install in editable mode with dev dependencies
127
+ pip install -e '.[dev]'
128
+
129
+ # Run the test suite
130
+ pytest
131
+
132
+ # Format code with black
133
+ black mailops/
134
+
135
+ # Sort imports with isort
136
+ isort mailops/
137
+ ```
138
+
139
+ ## 🤝 Contributing
140
+
141
+ We want to keep this lightweight and portable.
142
+
143
+ * **Standard Libs First**: We try to avoid external dependencies to ensure the tool runs anywhere.
144
+ * **Code Style**: We use `black` and `isort`.
145
+ * **See details**: Check [CONTRIBUTING.md](CONTRIBUTING.md) for the full guide.
146
+
147
+ ## 📄 License
148
+
149
+ MIT © [KnowOneActual](LICENSE)
150
+
151
+ ---
152
+
153
+ **Made with ❤️ for email operations**
154
+
155
+ ## 🗺️ Roadmap
156
+
157
+ [![Project Board](https://github.com/users/KnowOneActual/projects/2/views/1)](https://github.com/users/KnowOneActual/projects/2/views/1)
@@ -0,0 +1,179 @@
1
+ Metadata-Version: 2.4
2
+ Name: mail-ops-scripts
3
+ Version: 2.4.0
4
+ Summary: A unified operational toolkit for email server administration and DMARC analysis.
5
+ Author-email: Beau Bremer <beau.bremer@tutamial.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/KnowOneActual/mail-ops-scripts
8
+ Project-URL: Repository, https://github.com/KnowOneActual/mail-ops-scripts
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.8
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Provides-Extra: dev
15
+ Requires-Dist: pytest>=7.0; extra == "dev"
16
+ Requires-Dist: black>=23.0; extra == "dev"
17
+ Requires-Dist: isort>=5.12; extra == "dev"
18
+ Requires-Dist: mypy>=1.5; extra == "dev"
19
+ Requires-Dist: build; extra == "dev"
20
+ Requires-Dist: twine; extra == "dev"
21
+ Dynamic: license-file
22
+
23
+ <div align="center">
24
+ <img src="assets/img/mail-ops-scripts.webp" alt="mail ops scripts project logo" width="200">
25
+
26
+ # Mail Ops Scripts
27
+
28
+ [![PyPI Version](https://img.shields.io/pypi/v/mail-ops-scripts?color=blue&style=flat-square)](https://pypi.org/project/mail-ops-scripts/)
29
+ [![CI](https://github.com/KnowOneActual/mail-ops-scripts/actions/workflows/ci.yml/badge.svg)](https://github.com/KnowOneActual/mail-ops-scripts/actions/workflows/ci.yml)
30
+ [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
31
+ [![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
32
+ [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
33
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
34
+
35
+ **A unified operational toolkit for email server administration, security analysis, and reporting.**
36
+
37
+ ### 🚀 Now available on PyPI!
38
+ You can now install `mailops` globally with a single command.
39
+
40
+ </div>
41
+
42
+ ---
43
+
44
+ ## ⚡ Quick Start
45
+
46
+ Get the CLI installed directly from PyPI and start managing your mail operations in seconds.
47
+
48
+ ```bash
49
+ # Install via pip
50
+ pip install mail-ops-scripts
51
+
52
+ # Verify installation
53
+ mailops --help
54
+ ```
55
+
56
+ ## 🛠 The Toolkit
57
+
58
+ `mailops` is a single binary aimed at simplifying the fragmented world of email admin. No more juggling random bash scripts or online DNS checkers.
59
+
60
+ | Command | Description |
61
+ | :--- | :--- |
62
+ | **`mailops fetch`** | Connects to Gmail/Exchange via IMAP to download DMARC reports. |
63
+ | **`mailops report`** | Parses XML reports (.xml, .gz, .zip) into readable tables or CSVs with alerts. |
64
+ | **`mailops spf`** | Validates SPF records using Google's DNS-over-HTTPS (secure & cached). |
65
+ | **`mailops dkim`** | Generates 2048-bit RSA keys and formats the exact DNS TXT record you need. |
66
+
67
+ ## 🚀 Common Workflows
68
+
69
+ ### 1. The "Monday Morning" Check
70
+
71
+ Grab the last week's DMARC reports from your dedicated inbox and see if anyone is spoofing you.
72
+
73
+ ```bash
74
+ # 1. Download reports from your dmarc@ account
75
+ mailops fetch --user admin@example.com --password "app-password" --days 7
76
+
77
+ # 2. Analyze the data (view alerts only)
78
+ mailops report --alerts
79
+ ```
80
+
81
+ ### 2. Setting Up a New Domain
82
+
83
+ Spinning up a new sender? Generate your security keys and validate your DNS instantly.
84
+
85
+ ```bash
86
+ # 1. Generate DKIM keys (outputs to ./default.private)
87
+ mailops dkim example.com --selector=mail
88
+
89
+ # 2. Verify your SPF record is live and valid
90
+ mailops spf example.com
91
+ ```
92
+
93
+ ### 3. Generate DMARC Analysis Report
94
+
95
+ Export your DMARC data to CSV for security team review or further analysis.
96
+
97
+ ```bash
98
+ # Display all records in formatted table
99
+ mailops report
100
+
101
+ # Export all records to CSV
102
+ mailops report --csv dmarc_analysis.csv
103
+
104
+ # Export only authentication failures to CSV
105
+ mailops report --alerts --csv security_alerts.csv
106
+ ```
107
+
108
+ ## 📊 Report Command Features
109
+
110
+ The `mailops report` command analyzes DMARC XML reports and provides:
111
+
112
+ - **Formatted Tables**: Color-coded analysis of SPF, DKIM, and DMARC policy results
113
+ - **Alert Filtering**: `--alerts` flag to show only authentication failures and spoofing attempts
114
+ - **CSV Export**: `--csv` flag to save results for further analysis
115
+ - **Compressed Format Support**: Automatically handles `.xml`, `.xml.gz`, and `.zip` files
116
+ - **Organized Output**: Groups results by organization and date range
117
+
118
+ ### Report Output Example
119
+
120
+ ```bash
121
+ $ mailops report
122
+ 📊 Analyzing REAL DMARC reports...
123
+ Found 5 XML files:
124
+ 📄 enterprise.protection.outlook.com!example.com!1765324800!1765411200.xml.gz
125
+ ...
126
+
127
+ Report: enterprise.protection.outlook.com (2025-12-01)
128
+ ─────────────────────────────────────────────────────────────────────────
129
+ Source IP | Hostname | Cnt | SPF | DKIM | Analysis
130
+ ─────────────────────────────────────────────────────────────────────────
131
+ 192.168.1.1 | mail.example.com | 42 | pass | pass | OK
132
+ 10.0.0.5 | suspicious.domain | 3 | fail | fail | INVESTIGATE
133
+ ```
134
+
135
+ ## 📦 Developer Setup
136
+
137
+ If you want to contribute or modify the scripts, here is how to get the dev environment running locally.
138
+
139
+ ```bash
140
+ # Clone and setup
141
+ git clone https://github.com/knowoneactual/mail-ops-scripts
142
+ cd mail-ops-scripts
143
+
144
+ # Create virtual env
145
+ python -m venv .venv
146
+ source .venv/bin/activate
147
+
148
+ # Install in editable mode with dev dependencies
149
+ pip install -e '.[dev]'
150
+
151
+ # Run the test suite
152
+ pytest
153
+
154
+ # Format code with black
155
+ black mailops/
156
+
157
+ # Sort imports with isort
158
+ isort mailops/
159
+ ```
160
+
161
+ ## 🤝 Contributing
162
+
163
+ We want to keep this lightweight and portable.
164
+
165
+ * **Standard Libs First**: We try to avoid external dependencies to ensure the tool runs anywhere.
166
+ * **Code Style**: We use `black` and `isort`.
167
+ * **See details**: Check [CONTRIBUTING.md](CONTRIBUTING.md) for the full guide.
168
+
169
+ ## 📄 License
170
+
171
+ MIT © [KnowOneActual](LICENSE)
172
+
173
+ ---
174
+
175
+ **Made with ❤️ for email operations**
176
+
177
+ ## 🗺️ Roadmap
178
+
179
+ [![Project Board](https://github.com/users/KnowOneActual/projects/2/views/1)](https://github.com/users/KnowOneActual/projects/2/views/1)
@@ -9,7 +9,7 @@ import sys
9
9
  sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
10
10
 
11
11
  from mailops.dkim_gen import generate_keys
12
- from mailops.dmarc_parser import parse_dmarc_xml
12
+ from mailops.dmarc_parser import parse_dmarc_xml, print_to_console, save_to_csv
13
13
  from mailops.imap_fetcher import fetch_reports
14
14
  from mailops.spf_check import fetch_spf_record
15
15
 
@@ -24,6 +24,12 @@ def main() -> None:
24
24
  2. mailops report --alerts
25
25
  3. mailops spf yourdomain.com
26
26
  4. mailops dkim yourdomain.com
27
+
28
+ 📊 REPORT EXAMPLES:
29
+ mailops report # Show all records in table
30
+ mailops report --alerts # Show only failures/spoofing
31
+ mailops report --csv results.csv # Export to CSV file
32
+ mailops report --alerts --csv alerts.csv # Export only failures to CSV
27
33
  """,
28
34
  )
29
35
 
@@ -39,11 +45,29 @@ def main() -> None:
39
45
  fetch_parser.add_argument("--server", default="imap.gmail.com", help="IMAP server")
40
46
 
41
47
  # REPORT
42
- report_parser = subparsers.add_parser("report", help="Analyze DMARC reports")
48
+ report_parser = subparsers.add_parser(
49
+ "report",
50
+ help="Analyze DMARC reports",
51
+ description="""Analyze DMARC XML reports (supports .xml, .xml.gz, .zip formats)
52
+
53
+ Examples:
54
+ mailops report # Display all records in formatted table
55
+ mailops report --alerts # Show only authentication failures & spoofing attempts
56
+ mailops report --csv out.csv # Export all records to CSV
57
+ mailops report --alerts --csv alerts.csv # Export only failures to CSV
58
+ """,
59
+ formatter_class=argparse.RawDescriptionHelpFormatter,
60
+ )
43
61
  report_parser.add_argument(
44
- "--alerts", action="store_true", help="Show only failures"
62
+ "--alerts",
63
+ action="store_true",
64
+ help="Show only failures and spoofing attempts (BLOCKED or INVESTIGATE status)",
65
+ )
66
+ report_parser.add_argument(
67
+ "--csv",
68
+ metavar="FILE",
69
+ help="Export results to CSV file (e.g., results.csv)",
45
70
  )
46
- report_parser.add_argument("--csv", help="Export to CSV")
47
71
 
48
72
  # DKIM
49
73
  dkim_parser = subparsers.add_parser("dkim", help="Generate DKIM keys")
@@ -69,12 +93,44 @@ def main() -> None:
69
93
 
70
94
  elif args.command == "report":
71
95
  print("📊 Analyzing REAL DMARC reports...")
72
- xml_files = glob.glob("*.xml") + glob.glob("reports/*.xml")
96
+ # FIXED: Include .gz and .zip files in search
97
+ xml_files = (
98
+ glob.glob("*.xml")
99
+ + glob.glob("reports/*.xml")
100
+ + glob.glob("*.gz")
101
+ + glob.glob("reports/*.gz")
102
+ + glob.glob("*.zip")
103
+ + glob.glob("reports/*.zip")
104
+ )
105
+
73
106
  if xml_files:
74
107
  print(f"Found {len(xml_files)} XML files:")
108
+ all_data = [] # FIXED: Accumulate all records
109
+
75
110
  for xml_file in xml_files:
76
111
  print(f" 📄 {xml_file}")
77
- parse_dmarc_xml(xml_file)
112
+ records = parse_dmarc_xml(xml_file) # FIXED: Capture returned data
113
+ all_data.extend(records) # FIXED: Add to collection
114
+
115
+ # FIXED: Apply alert filter if requested
116
+ if args.alerts:
117
+ all_data = [
118
+ r
119
+ for r in all_data
120
+ if r["status_msg"] in ["BLOCKED (Spoofing)", "INVESTIGATE"]
121
+ ]
122
+ if not all_data:
123
+ print(
124
+ "✅ No security alerts found - "
125
+ "all records passed authentication!"
126
+ )
127
+ return
128
+
129
+ # FIXED: Display results
130
+ if args.csv:
131
+ save_to_csv(all_data, args.csv)
132
+ else:
133
+ print_to_console(all_data)
78
134
  else:
79
135
  print("❌ No XML files found. Run 'mailops fetch' first!")
80
136
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "mail-ops-scripts"
7
- version = "2.2.0"
7
+ version = "2.4.0"
8
8
  description = "A unified operational toolkit for email server administration and DMARC analysis."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -8,7 +8,7 @@ def test_package_version():
8
8
  """Verify the package version matches pyproject.toml."""
9
9
  try:
10
10
  pkg_version = version("mail-ops-scripts")
11
- assert pkg_version == "2.2.0", f"Expected 2.2.0, got {pkg_version}"
11
+ assert pkg_version == "2.3.0", f"Expected 2.2.0, got {pkg_version}"
12
12
  except PackageNotFoundError:
13
13
  pytest.skip("mail-ops-scripts not installed in environment")
14
14
 
@@ -1,147 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: mail-ops-scripts
3
- Version: 2.2.0
4
- Summary: A unified operational toolkit for email server administration and DMARC analysis.
5
- Author-email: Beau Bremer <beau.bremer@tutamial.com>
6
- License: MIT
7
- Project-URL: Homepage, https://github.com/KnowOneActual/mail-ops-scripts
8
- Project-URL: Repository, https://github.com/KnowOneActual/mail-ops-scripts
9
- Classifier: Programming Language :: Python :: 3
10
- Classifier: Operating System :: OS Independent
11
- Requires-Python: >=3.8
12
- Description-Content-Type: text/markdown
13
- License-File: LICENSE
14
- Provides-Extra: dev
15
- Requires-Dist: pytest>=7.0; extra == "dev"
16
- Requires-Dist: black>=23.0; extra == "dev"
17
- Requires-Dist: isort>=5.12; extra == "dev"
18
- Requires-Dist: mypy>=1.5; extra == "dev"
19
- Requires-Dist: build; extra == "dev"
20
- Requires-Dist: twine; extra == "dev"
21
- Dynamic: license-file
22
-
23
- <div align="center">
24
- <img src="assets/img/mail-ops-scripts.webp" alt="mail ops scripts project logo" width="200">
25
-
26
- # Mail Ops Scripts
27
-
28
-
29
- [![CI](https://github.com/KnowOneActual/mail-ops-scripts/actions/workflows/ci.yml/badge.svg)](https://github.com/KnowOneActual/mail-ops-scripts/actions/workflows/ci.yml)
30
- [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
31
- [![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
32
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
33
- [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
34
-
35
- </div>
36
-
37
-
38
- A unified operational toolkit for email server administration, security analysis, and reporting.
39
-
40
- ## 🚀 COMMANDS STATUS
41
-
42
- | Command | Status | Tech |
43
- |---------|--------|------|
44
- | `mailops dkim example.com` | ✅ **FULLY LIVE** | OpenSSL key generation |
45
- | `mailops spf google.com` | ✅ **FULLY LIVE** | Google DNS-over-HTTPS |
46
- | `mailops report --alerts` | ✅ **FILE READY** | DMARC XML parsing |
47
- | `mailops fetch --user...` | ✅ **CREDS READY** | IMAPlib + Gmail/Outlook |
48
-
49
- ✅ LIVE = Real code executing (DKIM keys generated, SPF DNS lookups, XML parsing)
50
- ⏳ TODO = Structure ready but needs real implementation
51
- ❌ BROKEN = Import errors or crashes
52
-
53
-
54
- ## 🎯 PRODUCTION WORKFLOW
55
-
56
- ```
57
- 📥 1. Fetch reports → mailops fetch --user you@gmail.com --password app-pass --days 7
58
- 📊 2. Analyze + alerts → mailops report --alerts
59
- 🔍 3. SPF validation → mailops spf yourdomain.com
60
- 🔑 4. DKIM key generation → mailops dkim yourdomain.com --selector=mail
61
- ```
62
-
63
- ## 💾 Quick Start
64
-
65
- ```
66
- # Clone + setup
67
- git clone https://github.com/knowoneactual/mail-ops-scripts
68
- cd mail-ops-scripts
69
-
70
- # Virtual environment
71
- python -m venv .venv
72
- source .venv/bin/activate # Linux/Mac
73
- # .venv/bin/Activate.ps1 # Windows PowerShell
74
-
75
- # Install
76
- pip install -e .
77
-
78
- # Test
79
- mailops --help
80
- ```
81
-
82
- ## 📋 Commands Reference
83
-
84
- ```
85
- # DKIM Key Generation
86
- mailops dkim example.com # default selector
87
- mailops dkim example.com --selector=mail # custom selector
88
-
89
- # SPF Checking
90
- mailops spf google.com
91
- mailops spf yourdomain.com
92
-
93
- # DMARC Reports
94
- mailops report # All XML files
95
- mailops report --alerts # Failures only
96
- mailops report --csv output.csv # Export CSV
97
-
98
- # IMAP Fetching
99
- mailops fetch --user you@gmail.com --password app-password --days 7
100
- mailops fetch --user user@domain.com --server imap.domain.com --days 30
101
- ```
102
-
103
- ## 🎉 Features
104
-
105
- - ✅ **Real OpenSSL DKIM generation** → `selector.private` files
106
- - ✅ **Google DNS-over-HTTPS SPF** → Production DNS lookups
107
- - ✅ **DMARC XML parsing** → Console + CSV output
108
- - ✅ **IMAP report fetching** → Gmail/Outlook/Exchange ready
109
- - ✅ **Global CLI install** → `~/.local/bin/mailops`
110
- - ✅ **VS Code workflow** → Python/HTML/Bash integration
111
- - ✅ **Production ready** → Error handling + help text
112
-
113
- ## 🛠 Development
114
-
115
- ```
116
- # Dev dependencies
117
- pip install -e '.[dev]'
118
-
119
- # Code quality
120
- black .
121
- isort .
122
- mypy .
123
- pytest
124
- ```
125
-
126
- ## 📦 Build & Publish
127
-
128
- ```
129
- pip install build twine
130
- python -m build
131
- twine upload dist/*
132
- ```
133
-
134
- ## 📖 Changelog
135
- [CHANGELOG.md](CHANGELOG.md)
136
-
137
- ## 🤝 Contributing
138
- [CONTRIBUTING.md](CONTRIBUTING.md)
139
-
140
- ## 📄 License
141
- [MIT](LICENSE)
142
-
143
- ---
144
- **Made with ❤️ for email operations**
145
- [knowoneactual/mail-ops-scripts](https://github.com/knowoneactual/mail-ops-scripts)
146
-
147
-
@@ -1,125 +0,0 @@
1
- <div align="center">
2
- <img src="assets/img/mail-ops-scripts.webp" alt="mail ops scripts project logo" width="200">
3
-
4
- # Mail Ops Scripts
5
-
6
-
7
- [![CI](https://github.com/KnowOneActual/mail-ops-scripts/actions/workflows/ci.yml/badge.svg)](https://github.com/KnowOneActual/mail-ops-scripts/actions/workflows/ci.yml)
8
- [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
9
- [![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
10
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
11
- [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
12
-
13
- </div>
14
-
15
-
16
- A unified operational toolkit for email server administration, security analysis, and reporting.
17
-
18
- ## 🚀 COMMANDS STATUS
19
-
20
- | Command | Status | Tech |
21
- |---------|--------|------|
22
- | `mailops dkim example.com` | ✅ **FULLY LIVE** | OpenSSL key generation |
23
- | `mailops spf google.com` | ✅ **FULLY LIVE** | Google DNS-over-HTTPS |
24
- | `mailops report --alerts` | ✅ **FILE READY** | DMARC XML parsing |
25
- | `mailops fetch --user...` | ✅ **CREDS READY** | IMAPlib + Gmail/Outlook |
26
-
27
- ✅ LIVE = Real code executing (DKIM keys generated, SPF DNS lookups, XML parsing)
28
- ⏳ TODO = Structure ready but needs real implementation
29
- ❌ BROKEN = Import errors or crashes
30
-
31
-
32
- ## 🎯 PRODUCTION WORKFLOW
33
-
34
- ```
35
- 📥 1. Fetch reports → mailops fetch --user you@gmail.com --password app-pass --days 7
36
- 📊 2. Analyze + alerts → mailops report --alerts
37
- 🔍 3. SPF validation → mailops spf yourdomain.com
38
- 🔑 4. DKIM key generation → mailops dkim yourdomain.com --selector=mail
39
- ```
40
-
41
- ## 💾 Quick Start
42
-
43
- ```
44
- # Clone + setup
45
- git clone https://github.com/knowoneactual/mail-ops-scripts
46
- cd mail-ops-scripts
47
-
48
- # Virtual environment
49
- python -m venv .venv
50
- source .venv/bin/activate # Linux/Mac
51
- # .venv/bin/Activate.ps1 # Windows PowerShell
52
-
53
- # Install
54
- pip install -e .
55
-
56
- # Test
57
- mailops --help
58
- ```
59
-
60
- ## 📋 Commands Reference
61
-
62
- ```
63
- # DKIM Key Generation
64
- mailops dkim example.com # default selector
65
- mailops dkim example.com --selector=mail # custom selector
66
-
67
- # SPF Checking
68
- mailops spf google.com
69
- mailops spf yourdomain.com
70
-
71
- # DMARC Reports
72
- mailops report # All XML files
73
- mailops report --alerts # Failures only
74
- mailops report --csv output.csv # Export CSV
75
-
76
- # IMAP Fetching
77
- mailops fetch --user you@gmail.com --password app-password --days 7
78
- mailops fetch --user user@domain.com --server imap.domain.com --days 30
79
- ```
80
-
81
- ## 🎉 Features
82
-
83
- - ✅ **Real OpenSSL DKIM generation** → `selector.private` files
84
- - ✅ **Google DNS-over-HTTPS SPF** → Production DNS lookups
85
- - ✅ **DMARC XML parsing** → Console + CSV output
86
- - ✅ **IMAP report fetching** → Gmail/Outlook/Exchange ready
87
- - ✅ **Global CLI install** → `~/.local/bin/mailops`
88
- - ✅ **VS Code workflow** → Python/HTML/Bash integration
89
- - ✅ **Production ready** → Error handling + help text
90
-
91
- ## 🛠 Development
92
-
93
- ```
94
- # Dev dependencies
95
- pip install -e '.[dev]'
96
-
97
- # Code quality
98
- black .
99
- isort .
100
- mypy .
101
- pytest
102
- ```
103
-
104
- ## 📦 Build & Publish
105
-
106
- ```
107
- pip install build twine
108
- python -m build
109
- twine upload dist/*
110
- ```
111
-
112
- ## 📖 Changelog
113
- [CHANGELOG.md](CHANGELOG.md)
114
-
115
- ## 🤝 Contributing
116
- [CONTRIBUTING.md](CONTRIBUTING.md)
117
-
118
- ## 📄 License
119
- [MIT](LICENSE)
120
-
121
- ---
122
- **Made with ❤️ for email operations**
123
- [knowoneactual/mail-ops-scripts](https://github.com/knowoneactual/mail-ops-scripts)
124
-
125
-
@@ -1,147 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: mail-ops-scripts
3
- Version: 2.2.0
4
- Summary: A unified operational toolkit for email server administration and DMARC analysis.
5
- Author-email: Beau Bremer <beau.bremer@tutamial.com>
6
- License: MIT
7
- Project-URL: Homepage, https://github.com/KnowOneActual/mail-ops-scripts
8
- Project-URL: Repository, https://github.com/KnowOneActual/mail-ops-scripts
9
- Classifier: Programming Language :: Python :: 3
10
- Classifier: Operating System :: OS Independent
11
- Requires-Python: >=3.8
12
- Description-Content-Type: text/markdown
13
- License-File: LICENSE
14
- Provides-Extra: dev
15
- Requires-Dist: pytest>=7.0; extra == "dev"
16
- Requires-Dist: black>=23.0; extra == "dev"
17
- Requires-Dist: isort>=5.12; extra == "dev"
18
- Requires-Dist: mypy>=1.5; extra == "dev"
19
- Requires-Dist: build; extra == "dev"
20
- Requires-Dist: twine; extra == "dev"
21
- Dynamic: license-file
22
-
23
- <div align="center">
24
- <img src="assets/img/mail-ops-scripts.webp" alt="mail ops scripts project logo" width="200">
25
-
26
- # Mail Ops Scripts
27
-
28
-
29
- [![CI](https://github.com/KnowOneActual/mail-ops-scripts/actions/workflows/ci.yml/badge.svg)](https://github.com/KnowOneActual/mail-ops-scripts/actions/workflows/ci.yml)
30
- [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
31
- [![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
32
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
33
- [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
34
-
35
- </div>
36
-
37
-
38
- A unified operational toolkit for email server administration, security analysis, and reporting.
39
-
40
- ## 🚀 COMMANDS STATUS
41
-
42
- | Command | Status | Tech |
43
- |---------|--------|------|
44
- | `mailops dkim example.com` | ✅ **FULLY LIVE** | OpenSSL key generation |
45
- | `mailops spf google.com` | ✅ **FULLY LIVE** | Google DNS-over-HTTPS |
46
- | `mailops report --alerts` | ✅ **FILE READY** | DMARC XML parsing |
47
- | `mailops fetch --user...` | ✅ **CREDS READY** | IMAPlib + Gmail/Outlook |
48
-
49
- ✅ LIVE = Real code executing (DKIM keys generated, SPF DNS lookups, XML parsing)
50
- ⏳ TODO = Structure ready but needs real implementation
51
- ❌ BROKEN = Import errors or crashes
52
-
53
-
54
- ## 🎯 PRODUCTION WORKFLOW
55
-
56
- ```
57
- 📥 1. Fetch reports → mailops fetch --user you@gmail.com --password app-pass --days 7
58
- 📊 2. Analyze + alerts → mailops report --alerts
59
- 🔍 3. SPF validation → mailops spf yourdomain.com
60
- 🔑 4. DKIM key generation → mailops dkim yourdomain.com --selector=mail
61
- ```
62
-
63
- ## 💾 Quick Start
64
-
65
- ```
66
- # Clone + setup
67
- git clone https://github.com/knowoneactual/mail-ops-scripts
68
- cd mail-ops-scripts
69
-
70
- # Virtual environment
71
- python -m venv .venv
72
- source .venv/bin/activate # Linux/Mac
73
- # .venv/bin/Activate.ps1 # Windows PowerShell
74
-
75
- # Install
76
- pip install -e .
77
-
78
- # Test
79
- mailops --help
80
- ```
81
-
82
- ## 📋 Commands Reference
83
-
84
- ```
85
- # DKIM Key Generation
86
- mailops dkim example.com # default selector
87
- mailops dkim example.com --selector=mail # custom selector
88
-
89
- # SPF Checking
90
- mailops spf google.com
91
- mailops spf yourdomain.com
92
-
93
- # DMARC Reports
94
- mailops report # All XML files
95
- mailops report --alerts # Failures only
96
- mailops report --csv output.csv # Export CSV
97
-
98
- # IMAP Fetching
99
- mailops fetch --user you@gmail.com --password app-password --days 7
100
- mailops fetch --user user@domain.com --server imap.domain.com --days 30
101
- ```
102
-
103
- ## 🎉 Features
104
-
105
- - ✅ **Real OpenSSL DKIM generation** → `selector.private` files
106
- - ✅ **Google DNS-over-HTTPS SPF** → Production DNS lookups
107
- - ✅ **DMARC XML parsing** → Console + CSV output
108
- - ✅ **IMAP report fetching** → Gmail/Outlook/Exchange ready
109
- - ✅ **Global CLI install** → `~/.local/bin/mailops`
110
- - ✅ **VS Code workflow** → Python/HTML/Bash integration
111
- - ✅ **Production ready** → Error handling + help text
112
-
113
- ## 🛠 Development
114
-
115
- ```
116
- # Dev dependencies
117
- pip install -e '.[dev]'
118
-
119
- # Code quality
120
- black .
121
- isort .
122
- mypy .
123
- pytest
124
- ```
125
-
126
- ## 📦 Build & Publish
127
-
128
- ```
129
- pip install build twine
130
- python -m build
131
- twine upload dist/*
132
- ```
133
-
134
- ## 📖 Changelog
135
- [CHANGELOG.md](CHANGELOG.md)
136
-
137
- ## 🤝 Contributing
138
- [CONTRIBUTING.md](CONTRIBUTING.md)
139
-
140
- ## 📄 License
141
- [MIT](LICENSE)
142
-
143
- ---
144
- **Made with ❤️ for email operations**
145
- [knowoneactual/mail-ops-scripts](https://github.com/knowoneactual/mail-ops-scripts)
146
-
147
-