feat: auto-email sending via SMTP (--send flag)

Closes #45

- New redmine_reporter/mailer.py: SMTP email sending with
  {author}/{period} template substitution, MIME attachment
  with correct content-type per file extension
- Config.get_email_config(): returns EmailConfig from YAML
  or None when not configured
- CLI --send flag: sends report after generation, works with
  --output, --commit, or standalone (saves to template path)
- 31 new tests (22 mailer + 6 CLI + 3 config)
- 249/249 tests passing, ruff clean, mypy clean
This commit is contained in:
Кокос Артем Николаевич
2026-07-10 12:37:02 +07:00
parent b926dd0d49
commit b0e353c565
7 changed files with 693 additions and 63 deletions

View File

@@ -343,6 +343,16 @@ class Config:
return cls._app.output_default_format or "xlsx"
return "xlsx"
@classmethod
def get_email_config(cls) -> "EmailConfig | None":
"""Возвращает EmailConfig из YAML-конфига или None, если не настроен."""
if cls._app is None:
return None
email = cls._app.email
if not email.smtp.host:
return None
return email
@classmethod
def get_default_date_range(cls) -> str:
from_env = os.getenv("DEFAULT_FROM_DATE", "").strip()