#37345: Add mailer shorthand for mailers[DEFAULT_MAILER_ALIAS]
-------------------------------------+-------------------------------------
Reporter: Johannes Maron | Owner:
Type: | ssknight-23
Cleanup/optimization | Status: closed
Component: Core (Mail) | Version: 6.1
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mike Edmunds):
* resolution: => invalid
* status: assigned => closed
Comment:
As pointed out in comment:1, `django.core.mail.mailers.default` returns
the default mailer instance
([
https://docs.djangoproject.com/en/6.1/topics/email/#django.core.mail.mailers.default
docs]). It is
[
https://github.com/django/deps/blob/main/accepted/0018-mailers.md
#mailers-factory:~:text=mailers.default%20is,the%20next%20section.) meant
to parallel] `django.db.connection`, `django.core.cache.cache`,
`django.tasks.default_task_backend`, and similar accessors.
We can't create a module-level accessor like
`django.core.mail.default_mailer`, because Django's `ConnectionProxy` and
`LazyObject` helpers (used for module-level accessors) require cacheable
instances. In general, `EmailBackend` instances
[
https://github.com/django/deps/blob/main/accepted/0018-mailers.md
#mailers-instances-are-not-cached are not cacheable].
--
Ticket URL: <
https://code.djangoproject.com/ticket/37345#comment:4>