Changes between Initial Version and Version 1 of Ticket #35514, comment 19


Ignore:
Timestamp:
Feb 12, 2026, 11:00:57 AM (2 weeks ago)
Author:
Mike Edmunds

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #35514, comment 19

    initial v1  
    1313   [[BR]][[BR]](More detail in [https://github.com/django/django/pull/18421#pullrequestreview-2624473570 this PR comment] and the ones following, plus several related suggested edits.)
    1414
    15 B. Can we require that (Django's built-in) EmailBackend instances ''must'' be obtained by calling mail.get_connection(), or do we need to continue allowing code to construct them directly?
    16    [[BR]][[BR]]If we can require get_connection(), it simplifies the backwards compatibility code in each EmailBackend somewhat. But it requires updating nearly all of Django's existing EmailBackend tests, which tend to call the constructor directly. (The current PR includes most of those test updates; we'd likely want to pull them into a separate "refs" commit first to prove they run correctly before this change.)
    17    [[BR]][[BR]]The relevant docs start at [https://docs.djangoproject.com/en/6.0/topics/email/#obtaining-an-instance-of-an-email-backend Obtaining an instance of an email backend]: "The `get_connection()` function in `django.core.mail` returns an instance of the email backend that you can use." But they go on to document available options for backends.smtp.EmailBackend() using the class constructor format.
    18    [[BR]][[BR]]I don't know whether that means we have documented smtp.EmailBackend as a class, so the constructor must remain callable for backwards compatibility. Or if it was just a convenient docutils syntax for describing SMTP EmailBackend options that can be used as keywords to get_connection(). (I can't imagine why real-world code would want to call an EmailBackend constructor directly rather than going through get_connection().)
     15B. ~~Can we require that (Django's built-in) EmailBackend instances ''must'' be obtained by calling mail.get_connection(), or do we need to continue allowing code to construct them directly?~~
     16   [[BR]][[BR]]~~If we can require get_connection(), it simplifies the backwards compatibility code in each EmailBackend somewhat. But it requires updating nearly all of Django's existing EmailBackend tests, which tend to call the constructor directly. (The current PR includes most of those test updates; we'd likely want to pull them into a separate "refs" commit first to prove they run correctly before this change.)~~
     17   [[BR]][[BR]]~~The relevant docs start at [https://docs.djangoproject.com/en/6.0/topics/email/#obtaining-an-instance-of-an-email-backend Obtaining an instance of an email backend]: "The `get_connection()` function in `django.core.mail` returns an instance of the email backend that you can use." But they go on to document available options for backends.smtp.EmailBackend() using the class constructor format.~~
     18   [[BR]][[BR]]~~I don't know whether that means we have documented smtp.EmailBackend as a class, so the constructor must remain callable for backwards compatibility. Or if it was just a convenient docutils syntax for describing SMTP EmailBackend options that can be used as keywords to get_connection(). (I can't imagine why real-world code would want to call an EmailBackend constructor directly rather than going through get_connection().)~~
     19   [[BR]][[BR]][Edit 2026-02-12: with the updated `mail.providers[alias]` API and related changes, I think this is no longer a concern. Tests can continue to call backend constructors directly, and should just add an `alias="anything"` arg to avoid deprecated initialization.]
    1920
    2021C. I think there was also some question about maybe deprecating the `backend` param to get_connection(). Or how and where to support new provider alias params alongside existing `connection` params in other django.core.mail APIs. (But I'm blanking on the details right now.)
Back to Top