feat: add scheduler and mail outbox

SMTP adapter with TLS and a fake, outbox with retries, backoff, rate limit and restart safety, scheduler tick with job-run records started by gunicorn, and a send_test_mail command.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N3t4WL7bd9bdHHNjEsxzqC
This commit is contained in:
2026-10-18 09:18:42 +02:00
co-authored by Claude Sonnet 5.5
parent 0dc079a8ac
commit 20510a73e5
40 changed files with 1315 additions and 6 deletions
+24
View File
@@ -0,0 +1,24 @@
"""In-memory mail server for tests (AD-1)."""
from __future__ import annotations
from .base import MailMessage, MailRejected, MailUnavailable
class FakeMailer:
"""Records what was sent. `unavailable` makes every send fail temporarily; recipients in
`rejected` are refused for good."""
def __init__(self) -> None:
self.sent: list[MailMessage] = []
self.unavailable = False
self.rejected: set[str] = set()
self.attempts = 0
def send(self, message: MailMessage) -> None:
self.attempts += 1
if self.unavailable:
raise MailUnavailable("The mail server is not available")
if message.recipient in self.rejected:
raise MailRejected("The mail server refused the message (550)")
self.sent.append(message)