Opened 92 minutes ago
#37261 assigned Bug
AdminEmailHandler and BrokenLinkEmailsMiddleware raise on email transport errors when MAILERS is configured
| Reported by: | Adam Johnson | Owned by: | Adam Johnson |
|---|---|---|---|
| Component: | Core (Mail) | Version: | 6.1 |
| Severity: | Release blocker | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Since #35514, Django’s built-in error reporting emails (admin emails and broken-link emails) raise on any transport error when the new dictionary-based MAILERS setting is configured, instead of failing silently as they did in Django 6.0.
Specifically:
AdminEmailHandler.emit()has no surrounding try/except, and Python's logging machinery does not contain exceptions raised byemit(), so the transport error is raised at thelogger.error(...)/logger.exception(...)call site — i.e. inside Django's own error-handling path while reporting a 500.
BrokenLinkEmailsMiddleware.process_response()raises on every referred 404, turning it into a 500.
The new "Migrating email to mailers" howto recommends wrapping sends in an error handler with try: / except Exception: pass "to avoid cascading failures inan error handler that sends mail".
We need to apply that advice to Django's own built-in error handlers!