E-mailfeature Operations: deployment, monitoring, productiegereedheid; configuratiefouten als Error-log

Mislukte mails door een configuratieprobleem (auth_failed, rejected_sender, tls_failed, not_configured) worden
als Error gelogd zodat Sentry een alert stuurt; timeouts en ontvangerproblemen blijven Warning.
Documentatie: uitrol per host met de hand in shared/env, rollback, monitoringplan, checklist; ASF-productie op
IIS als open punt voor een latere feature.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-09 09:24:19 +01:00
co-authored by Claude Sonnet 5.5
parent 0e86125f12
commit 3a9e4ae7aa
13 changed files with 243 additions and 12 deletions
@@ -0,0 +1,23 @@
# Monitoring plan - identity-email-notifications
Decisions (Q4 B, Q5 A): journal plus Sentry on the existing tooling; no new dashboards; no threshold rule.
## Signals (structured log events, never with credentials, addresses, tokens or links)
| Event | Level | When | Meaning |
|---|---|---|---|
| `mail_status enabled=true|false ...` | Information | every start | whether mail is on, with SMTP host, port, STARTTLS and the default sender DOMAIN |
| `mail_configuration_invalid: ... {settings}` | **Error** | start, once | an SMTP host is set but the configuration is incomplete or invalid: mail stays OFF; names the settings |
| `identity_mail_failed code=auth_failed / rejected_sender / tls_failed / not_configured` | **Error** | per failed mail | configuration problem, somebody has to fix it (wrong credentials, a sender the account may not use, TLS, no host) |
| `identity_mail_failed code=timeout_* / rejected_recipient / rejected / connection_failed / unknown` | Warning | per failed mail | passes by itself or concerns one message; journal and breadcrumbs only |
| `identity_mail_sent kind=... recipient_domain=...` | Information | per sent mail | volume, no address |
| `password_reset_request_ignored`, `password_reset_completed`, `password_reset_request_failed` | Information / Warning | reset flow | cooldown hits, completed resets |
## Alerting (Sentry, existing project of each site, notification by e-mail to the project owner)
Sentry turns Error events into issues. Create one rule per environment (test and production) in the site's Sentry project:
- **Rule "mail configuration problem"**: when an issue is created or reopened and its message contains `identity_mail_failed` or `mail_configuration_invalid` (level Error), notify the project owner by e-mail. No frequency threshold (Q4 B).
Nothing else: timeouts and recipient problems are not alerted.
## Where to look
- Pi: `journalctl --user -u <unit> | grep -E "mail_status|identity_mail_|mail_configuration_invalid"`.
- IIS (later): the stdout log or the event log of the app pool (to be settled in the ASF-production work).
- Sentry: issues filtered on `environment:<test|production>`.
@@ -0,0 +1,13 @@
# Monitoring setup - identity-email-notifications
## Done in code (this feature)
- The log level follows the kind of failure: Error for configuration problems (`auth_failed`, `rejected_sender`, `tls_failed`, `not_configured`), Warning for the rest, so Sentry alerts only when somebody has to act. Tested (`SmtpSenderDiagnosticsTests`: wrong login and refused sender are Error events, refused recipient and timeouts stay Warning; level mapping for every code; no secret in any line).
- A start-up line states whether mail is on, and an Error names every missing or invalid setting when it is not.
## To be done by a person (the assistant does not change shared Sentry projects)
1. In the Sentry project of ASF (environment `test`) and of SlpSoftware (environments `test`, later `production`): create the issue-alert rule of the monitoring plan (message contains `identity_mail_failed` or `mail_configuration_invalid`, notify the owner by e-mail). The `sentry:sentry-create-alert` skill can create it on request, with Bryan's go.
2. Check once per host after switching mail on: the journal shows `mail_status enabled=true`.
3. Trigger the alert once on test (for example a wrong password in `shared/env` for a minute) to see that the e-mail arrives; restore the password.
## Runbook lines (Q5 A)
After any change of mail settings: restart, read the journal for `mail_status enabled=true` or `mail_configuration_invalid`, check `/System/capabilities` for `emailEnabled`.