kctl-mailcow 0.2.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 (59) hide show
  1. kctl_mailcow-0.2.0/.gitignore +33 -0
  2. kctl_mailcow-0.2.0/PKG-INFO +19 -0
  3. kctl_mailcow-0.2.0/README.md +343 -0
  4. kctl_mailcow-0.2.0/pyproject.toml +49 -0
  5. kctl_mailcow-0.2.0/skills/mailcow-admin/SKILL.md +376 -0
  6. kctl_mailcow-0.2.0/src/kctl_mailcow/__init__.py +3 -0
  7. kctl_mailcow-0.2.0/src/kctl_mailcow/__main__.py +5 -0
  8. kctl_mailcow-0.2.0/src/kctl_mailcow/cli.py +174 -0
  9. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/__init__.py +0 -0
  10. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/alias_domains.py +84 -0
  11. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/aliases.py +147 -0
  12. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/app_passwords.py +88 -0
  13. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/bcc_maps.py +102 -0
  14. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/config_cmd.py +462 -0
  15. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/dashboard.py +148 -0
  16. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/dkim.py +113 -0
  17. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/doctor_cmd.py +82 -0
  18. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/domain_admins.py +131 -0
  19. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/domains.py +206 -0
  20. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/fail2ban.py +67 -0
  21. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/filters.py +128 -0
  22. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/fwdhost.py +80 -0
  23. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/health.py +87 -0
  24. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/identity_provider.py +143 -0
  25. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/logs.py +69 -0
  26. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/mailboxes.py +273 -0
  27. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/oauth2_clients.py +103 -0
  28. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/password_policy.py +66 -0
  29. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/policies.py +132 -0
  30. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/provision.py +167 -0
  31. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/quarantine.py +96 -0
  32. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/queue.py +83 -0
  33. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/ratelimits.py +74 -0
  34. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/recipient_maps.py +66 -0
  35. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/relay_hosts.py +119 -0
  36. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/resources.py +87 -0
  37. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/rspamd.py +109 -0
  38. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/skill_cmd.py +76 -0
  39. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/status.py +132 -0
  40. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/sync_jobs.py +113 -0
  41. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/tls.py +86 -0
  42. kctl_mailcow-0.2.0/src/kctl_mailcow/commands/transports.py +143 -0
  43. kctl_mailcow-0.2.0/src/kctl_mailcow/core/__init__.py +0 -0
  44. kctl_mailcow-0.2.0/src/kctl_mailcow/core/callbacks.py +34 -0
  45. kctl_mailcow-0.2.0/src/kctl_mailcow/core/client.py +58 -0
  46. kctl_mailcow-0.2.0/src/kctl_mailcow/core/config.py +122 -0
  47. kctl_mailcow-0.2.0/src/kctl_mailcow/core/exceptions.py +23 -0
  48. kctl_mailcow-0.2.0/src/kctl_mailcow/core/helpers.py +62 -0
  49. kctl_mailcow-0.2.0/src/kctl_mailcow/core/output.py +7 -0
  50. kctl_mailcow-0.2.0/src/kctl_mailcow/core/provisioner.py +152 -0
  51. kctl_mailcow-0.2.0/tests/__init__.py +0 -0
  52. kctl_mailcow-0.2.0/tests/conftest.py +60 -0
  53. kctl_mailcow-0.2.0/tests/test_aliases.py +299 -0
  54. kctl_mailcow-0.2.0/tests/test_client.py +37 -0
  55. kctl_mailcow-0.2.0/tests/test_config.py +40 -0
  56. kctl_mailcow-0.2.0/tests/test_domains.py +357 -0
  57. kctl_mailcow-0.2.0/tests/test_exceptions.py +20 -0
  58. kctl_mailcow-0.2.0/tests/test_mailboxes.py +417 -0
  59. kctl_mailcow-0.2.0/tests/test_smoke.py +87 -0
@@ -0,0 +1,33 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ *.egg
6
+ dist/
7
+ build/
8
+ .eggs/
9
+
10
+ # Virtual environments
11
+ .venv/
12
+ venv/
13
+
14
+ # IDE
15
+ .idea/
16
+ .vscode/
17
+ *.swp
18
+ *.swo
19
+
20
+ # Testing
21
+ .pytest_cache/
22
+ .coverage
23
+ htmlcov/
24
+ .mypy_cache/
25
+ .ruff_cache/
26
+
27
+ # OS
28
+ .DS_Store
29
+ Thumbs.db
30
+
31
+ # Environment
32
+ .env
33
+ .env.local
@@ -0,0 +1,19 @@
1
+ Metadata-Version: 2.4
2
+ Name: kctl-mailcow
3
+ Version: 0.2.0
4
+ Summary: Kodemeio Mailcow CLI — manage your Mailcow mail server
5
+ Requires-Python: >=3.12
6
+ Requires-Dist: httpx>=0.28.0
7
+ Requires-Dist: kctl-lib>=0.4.0
8
+ Requires-Dist: pydantic>=2.10.0
9
+ Requires-Dist: pyyaml>=6.0.2
10
+ Requires-Dist: rich>=13.9.0
11
+ Requires-Dist: typer>=0.15.0
12
+ Provides-Extra: dev
13
+ Requires-Dist: mypy>=1.14.0; extra == 'dev'
14
+ Requires-Dist: pytest-httpx>=0.35.0; extra == 'dev'
15
+ Requires-Dist: pytest>=8.3.0; extra == 'dev'
16
+ Requires-Dist: ruff>=0.9.0; extra == 'dev'
17
+ Requires-Dist: types-pyyaml>=6.0.0; extra == 'dev'
18
+ Provides-Extra: provision
19
+ Requires-Dist: kctl-ak>=0.1.0; extra == 'provision'
@@ -0,0 +1,343 @@
1
+ # kctl-mailcow
2
+
3
+ Kodemeio Mailcow CLI -- manage your Mailcow mail server via the REST API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ uv tool install ./packages/kctl-mailcow
9
+ ```
10
+
11
+ To upgrade after code changes:
12
+
13
+ ```bash
14
+ uv tool install --force --reinstall ./packages/kctl-mailcow
15
+ ```
16
+
17
+ With Authentik provisioning support:
18
+
19
+ ```bash
20
+ uv tool install "./packages/kctl-mailcow[provision]"
21
+ ```
22
+
23
+ ## Quick Start
24
+
25
+ ```bash
26
+ # Configure connection (interactive)
27
+ kctl-mailcow config init
28
+
29
+ # Verify connectivity
30
+ kctl-mailcow config test
31
+
32
+ # Dashboard overview
33
+ kctl-mailcow dashboard
34
+
35
+ # List all domains
36
+ kctl-mailcow domains list
37
+
38
+ # List all mailboxes
39
+ kctl-mailcow mailboxes list
40
+
41
+ # Check server health
42
+ kctl-mailcow health
43
+ ```
44
+
45
+ ## Command Groups
46
+
47
+ | Group | Description |
48
+ |---------------------|--------------------------------------------------------------------|
49
+ | `domains` | Manage mail domains (list, get, add, update, delete, dns-check) |
50
+ | `mailboxes` | Manage mailboxes (list, get, add, update, delete) |
51
+ | `aliases` | Manage email aliases (list, get, add, update, delete) |
52
+ | `alias-domains` | Manage whole-domain aliases (domain-level aliasing) |
53
+ | `dkim` | Manage DKIM keys (list, get, generate) |
54
+ | `queue` | Manage mail queue (list, flush, delete) |
55
+ | `quarantine` | Manage quarantined messages |
56
+ | `logs` | View Mailcow service logs |
57
+ | `status` | Server status and health overview |
58
+ | `health` | Health checks for Mailcow services |
59
+ | `dashboard` | System overview dashboard |
60
+ | `sync-jobs` | Manage IMAP sync jobs |
61
+ | `fwdhost` | Manage forwarding hosts |
62
+ | `tls` | Manage TLS policy maps |
63
+ | `resources` | Manage Mailcow resource limits |
64
+ | `ratelimits` | Manage per-mailbox or per-domain rate limits |
65
+ | `identity-provider` | Manage external identity provider (OIDC SSO) for admin login |
66
+ | `oauth2-clients` | Manage OAuth2 clients (Mailcow as OAuth2 provider) |
67
+ | `provision` | Provision mailboxes from Authentik users |
68
+ | `fail2ban` | Manage fail2ban bans (list, add, delete) |
69
+ | `policies` | Manage spam whitelist/blacklist policies |
70
+ | `app-passwords` | Manage per-mailbox app passwords |
71
+ | `password-policy` | Manage global password policy |
72
+ | `domain-admins` | Manage domain administrators |
73
+ | `filters` | Manage per-mailbox Sieve filters |
74
+ | `transports` | Manage outbound transport maps |
75
+ | `relay-hosts` | Manage sender-dependent relay hosts |
76
+ | `bcc-maps` | Manage BCC maps for compliance copies |
77
+ | `recipient-maps` | Manage recipient maps (inbound address rewriting) |
78
+ | `rspamd` | Manage rspamd spam filter settings |
79
+ | `config` | CLI configuration (profiles, init, test, show) |
80
+
81
+ ## Global Options
82
+
83
+ | Option | Short | Description |
84
+ |---------------------|-------|------------------------------------|
85
+ | `--json` | | Output as JSON |
86
+ | `--quiet` | `-q` | Suppress info messages |
87
+ | `--profile` | `-p` | Config profile name |
88
+ | `--url` | | API URL override (per-invocation) |
89
+ | `--api-key` | | API key override (per-invocation) |
90
+ | `--version` | `-V` | Show version and exit |
91
+
92
+ ## Configuration
93
+
94
+ Configuration is stored in `~/.config/kodemeio/config.yaml` under the `mailcow` service key.
95
+
96
+ ### Initialize a profile
97
+
98
+ ```bash
99
+ kctl-mailcow config init
100
+ ```
101
+
102
+ This prompts for:
103
+ - Mailcow base URL (e.g. `https://mail.example.com`)
104
+ - API key (generate in Mailcow UI under Configuration > Access > API)
105
+
106
+ ### Multiple profiles
107
+
108
+ ```bash
109
+ # Add a second profile
110
+ kctl-mailcow config add --profile staging
111
+
112
+ # Switch active profile
113
+ kctl-mailcow config use staging
114
+
115
+ # List all profiles
116
+ kctl-mailcow config profiles
117
+
118
+ # Show current profile (secrets masked)
119
+ kctl-mailcow config show
120
+ ```
121
+
122
+ ### Environment variable override
123
+
124
+ ```bash
125
+ export MAILCOW_URL=https://mail.example.com
126
+ export MAILCOW_API_KEY=your-api-key
127
+ kctl-mailcow domains list
128
+ ```
129
+
130
+ Or override per-invocation:
131
+
132
+ ```bash
133
+ kctl-mailcow --url https://mail.example.com --api-key <key> domains list
134
+ ```
135
+
136
+ ## Common Workflows
137
+
138
+ ### Domain management
139
+
140
+ ```bash
141
+ # List domains with alias/mailbox quotas
142
+ kctl-mailcow domains list
143
+
144
+ # Add a new domain
145
+ kctl-mailcow domains add example.com --aliases 100 --mailboxes 50 --quota 10240
146
+
147
+ # Check DNS records for a domain
148
+ kctl-mailcow domains dns-check example.com
149
+
150
+ # Deactivate a domain
151
+ kctl-mailcow domains update example.com --active 0
152
+ ```
153
+
154
+ ### Mailbox management
155
+
156
+ ```bash
157
+ # List mailboxes, optionally filtered by domain
158
+ kctl-mailcow mailboxes list
159
+ kctl-mailcow mailboxes list --domain example.com
160
+
161
+ # Add a mailbox
162
+ kctl-mailcow mailboxes add user@example.com --name "Full Name" --quota 2048
163
+
164
+ # Get mailbox details
165
+ kctl-mailcow mailboxes get user@example.com
166
+
167
+ # Delete a mailbox
168
+ kctl-mailcow mailboxes delete user@example.com
169
+ ```
170
+
171
+ ### DKIM management
172
+
173
+ ```bash
174
+ # List DKIM selectors
175
+ kctl-mailcow dkim list
176
+
177
+ # Generate DKIM key for a domain
178
+ kctl-mailcow dkim generate example.com
179
+
180
+ # Get DKIM public key (for DNS record)
181
+ kctl-mailcow dkim get example.com
182
+ ```
183
+
184
+ ### Authentik provisioning
185
+
186
+ Provision mailboxes automatically from Authentik group membership:
187
+
188
+ ```bash
189
+ # Dry-run: preview what would be created
190
+ kctl-mailcow provision sync --group "Mail Users" --domain example.com --dry-run
191
+
192
+ # Sync users to mailboxes (creates new, skips existing)
193
+ kctl-mailcow provision sync --group "Mail Users" --domain example.com
194
+
195
+ # Check provisioning status
196
+ kctl-mailcow provision status
197
+
198
+ # Use a specific Authentik profile
199
+ kctl-mailcow provision sync --group "Mail Users" --domain example.com --ak-profile staging
200
+ ```
201
+
202
+ Requires the `provision` extra: `uv tool install "./packages/kctl-mailcow[provision]"` and a configured `kctl-ak` profile.
203
+
204
+ ### Mail queue
205
+
206
+ ```bash
207
+ # View queued messages
208
+ kctl-mailcow queue list
209
+
210
+ # Flush (deliver) all queued messages
211
+ kctl-mailcow queue flush
212
+
213
+ # Delete all queued messages
214
+ kctl-mailcow queue delete
215
+ ```
216
+
217
+ ### Security & compliance
218
+
219
+ ```bash
220
+ # List fail2ban bans
221
+ kctl-mailcow fail2ban list
222
+
223
+ # Unban an IP
224
+ kctl-mailcow fail2ban delete 1.2.3.4
225
+
226
+ # Add spam whitelist entry
227
+ kctl-mailcow policies add-whitelist user@trusted.com
228
+
229
+ # Add spam blacklist entry
230
+ kctl-mailcow policies add-blacklist spammer@example.com
231
+
232
+ # Manage BCC maps (compliance copies)
233
+ kctl-mailcow bcc-maps list
234
+ kctl-mailcow bcc-maps add user@example.com --bcc compliance@corp.com
235
+ ```
236
+
237
+ ### OIDC / OAuth2 (Authentik SSO)
238
+
239
+ ```bash
240
+ # Configure external identity provider for admin login
241
+ kctl-mailcow identity-provider list
242
+ kctl-mailcow identity-provider add --provider authentik --client-id <id> --client-secret <secret>
243
+
244
+ # Manage OAuth2 clients (Mailcow as provider)
245
+ kctl-mailcow oauth2-clients list
246
+ kctl-mailcow oauth2-clients add --name "My App" --redirect-uri https://app.example.com/callback
247
+ ```
248
+
249
+ ### Monitoring & logs
250
+
251
+ ```bash
252
+ # View service logs (all services)
253
+ kctl-mailcow logs
254
+
255
+ # View logs for a specific service
256
+ kctl-mailcow logs --service postfix
257
+
258
+ # Server status summary
259
+ kctl-mailcow status
260
+
261
+ # Health check
262
+ kctl-mailcow health
263
+
264
+ # Full dashboard
265
+ kctl-mailcow dashboard
266
+ ```
267
+
268
+ ## Output Formats
269
+
270
+ All commands support multiple output formats:
271
+
272
+ ```bash
273
+ # Pretty table (default)
274
+ kctl-mailcow domains list
275
+
276
+ # JSON (for scripting / piping to jq)
277
+ kctl-mailcow domains list --json
278
+
279
+ # Quiet mode (suppress info messages)
280
+ kctl-mailcow mailboxes add user@example.com --name "Alice" --quota 1024 --quiet
281
+ ```
282
+
283
+ ## Development
284
+
285
+ ```bash
286
+ # Install in development mode
287
+ cd packages/kctl-mailcow
288
+ uv sync --all-extras
289
+
290
+ # Run tests
291
+ uv run pytest tests/ -v
292
+
293
+ # Lint
294
+ uv run ruff check src/
295
+
296
+ # Type check
297
+ uv run mypy src/
298
+
299
+ # Run CLI directly (without install)
300
+ uv run kctl-mailcow --help
301
+ ```
302
+
303
+ ### Project structure
304
+
305
+ ```
306
+ packages/kctl-mailcow/
307
+ ├── src/kctl_mailcow/
308
+ │ ├── cli.py # Main entry point, registers all command groups
309
+ │ ├── commands/ # One module per command group (31 groups)
310
+ │ │ ├── domains.py
311
+ │ │ ├── mailboxes.py
312
+ │ │ ├── aliases.py
313
+ │ │ └── ...
314
+ │ └── core/
315
+ │ ├── callbacks.py # AppContext — profile + client init
316
+ │ ├── client.py # Mailcow API client (extends APIClient)
317
+ │ ├── helpers.py # Shared output helpers
318
+ │ └── provisioner.py # Authentik → Mailcow provisioning logic
319
+ ├── tests/ # pytest test suite
320
+ └── pyproject.toml
321
+ ```
322
+
323
+ ### Adding a new command group
324
+
325
+ 1. Create `src/kctl_mailcow/commands/my_group.py` with a `typer.Typer` app
326
+ 2. Import and register it in `cli.py`:
327
+ ```python
328
+ from kctl_mailcow.commands.my_group import app as my_group_app
329
+ app.add_typer(my_group_app, name="my-group")
330
+ ```
331
+ 3. Add tests in `tests/test_my_group.py`
332
+
333
+ ## Dependencies
334
+
335
+ | Package | Purpose |
336
+ |--------------|--------------------------------------|
337
+ | `kctl-lib` | Shared CLI infrastructure (>=0.4.0) |
338
+ | `typer` | CLI framework |
339
+ | `rich` | Terminal formatting |
340
+ | `pydantic` | Data validation |
341
+ | `httpx` | HTTP client |
342
+ | `pyyaml` | YAML config parsing |
343
+ | `kctl-ak` | Authentik client (provision extra) |
@@ -0,0 +1,49 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "kctl-mailcow"
7
+ version = "0.2.0"
8
+ description = "Kodemeio Mailcow CLI — manage your Mailcow mail server"
9
+ requires-python = ">=3.12"
10
+ dependencies = [
11
+ "kctl-lib>=0.4.0",
12
+ "typer>=0.15.0",
13
+ "rich>=13.9.0",
14
+ "pydantic>=2.10.0",
15
+ "pyyaml>=6.0.2",
16
+ "httpx>=0.28.0",
17
+ ]
18
+
19
+ [project.optional-dependencies]
20
+ dev = [
21
+ "pytest>=8.3.0",
22
+ "pytest-httpx>=0.35.0",
23
+ "ruff>=0.9.0",
24
+ "mypy>=1.14.0",
25
+ "types-PyYAML>=6.0.0",
26
+ ]
27
+ provision = [
28
+ "kctl-ak>=0.1.0",
29
+ ]
30
+
31
+ [project.scripts]
32
+ kctl-mailcow = "kctl_mailcow.cli:_run"
33
+
34
+ [tool.uv.sources]
35
+ kctl-lib = { workspace = true }
36
+ kctl-ak = { workspace = true }
37
+
38
+ [project.entry-points."kctl_mailcow.plugins"]
39
+
40
+ [tool.hatch.build.targets.wheel]
41
+ packages = ["src/kctl_mailcow"]
42
+
43
+ [tool.ruff]
44
+ target-version = "py312"
45
+ line-length = 120
46
+
47
+ [tool.mypy]
48
+ python_version = "3.12"
49
+ strict = true