Opened 103 minutes ago
#37443 new New feature
Add support for email delivery using Django's Tasks framework.
| Reported by: | David Smith | Owned by: | |
|---|---|---|---|
| Component: | Core (Mail) | Version: | 6.1 |
| Severity: | Low | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
The PasswordResetView docs includes a warning that sending emails during a request can expose an email address enumeration timing attack. The recommendation is to send emails asynchronously with a link to django-mailer. At the time of writing django-mailer last saw a release on PyPI in 2024 (~2.5 years ago).
Given that Django now has an inbuilt tasks framework I propose that we use this to provide built-in integration for sending emails in the background.
Very broadly, Django would provide a way to opt-in to sending emails using django.tasks. It would be possible to create a task which sends an email using one of the configured mailers. This would allow existing code which sends emails, including the password reset view, to use the tasks framework to send emails. Production setups with a django tasks backend with a worker process would then be able to send emails in the background.
The django tasks framework would seem suited to this, with the first example in the docs being a task that sends an email. See docs.