From 80ea222c8af501031b2eae4f7d9fdbf16cb507a7 Mon Sep 17 00:00:00 2001 From: VIZZARD-X Date: Fri, 10 Jul 2026 21:46:16 +0530 Subject: Fixed #37167 -- Allowed email.headerregistry.Address objects as email addresses. Address is the safe way to build an email address with a display name from variable parts (see #34753), but `ADMINS` and `MANAGERS` rejected non-string values, so it could not be used there. This branch allows `Address` instances in those settings, documents, and tests the support already present in `DEFAULT_FROM_EMAIL`, `SERVER_EMAIL`, `send_mail()`, `send_mass_mail()`, and `EmailMessage`. Co-authored-by: Natalia <124304+nessita@users.noreply.github.com> --- docs/ref/settings.txt | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'docs/ref') diff --git a/docs/ref/settings.txt b/docs/ref/settings.txt index 304bb75ca3..674f676013 100644 --- a/docs/ref/settings.txt +++ b/docs/ref/settings.txt @@ -52,14 +52,17 @@ A list of all the people who get code error notifications. When is configured in :setting:`LOGGING` (done by default), Django emails these people the details of exceptions raised in the request/response cycle. -Each item in the list should be an email address string. Example:: +Each item in the list should be an email address string or +:class:`~email.headerregistry.Address` object. Example:: ADMINS = ["john@example.com", '"Ng, Mary" '] To safely build an address with a display name from variable content, see -:ref:`formatting-addresses`, which recommends using -:class:`~email.headerregistry.Address` over string formatting, but since this -setting requires a list of strings, wrap each ``Address`` in ``str(...)``. +:ref:`formatting-addresses`. + +.. versionchanged:: 6.2 + + Support for :class:`~email.headerregistry.Address` objects was added. .. setting:: ALLOWED_HOSTS @@ -1359,6 +1362,10 @@ This doesn't affect error messages sent to :setting:`ADMINS` and To build an address with a display name from variable content, see :ref:`formatting-addresses`. +.. versionchanged:: 6.2 + + Support for :class:`~email.headerregistry.Address` objects was added. + .. setting:: DEFAULT_INDEX_TABLESPACE ``DEFAULT_INDEX_TABLESPACE`` @@ -2250,6 +2257,10 @@ A list in the same format as :setting:`ADMINS` that specifies who should get broken link notifications when :class:`~django.middleware.common.BrokenLinkEmailsMiddleware` is enabled. +.. versionchanged:: 6.2 + + Support for :class:`~email.headerregistry.Address` objects was added. + .. setting:: MEDIA_ROOT ``MEDIA_ROOT`` @@ -2818,6 +2829,10 @@ To build an address with a display name from variable content, see regular email messages sent with :func:`~django.core.mail.send_mail` come from; for that, see :setting:`DEFAULT_FROM_EMAIL`. +.. versionchanged:: 6.2 + + Support for :class:`~email.headerregistry.Address` objects was added. + .. setting:: SHORT_DATE_FORMAT ``SHORT_DATE_FORMAT`` -- cgit v1.3