[Django] #36894: Email fail_silently, auth_user, auth_password are ignored when connection param provided

3 views
Skip to first unread message

Django

unread,
Jan 30, 2026, 4:54:56 PMJan 30
to django-...@googlegroups.com
#36894: Email fail_silently, auth_user, auth_password are ignored when connection
param provided
------------------------------+---------------------------------------
Reporter: Mike Edmunds | Type: Bug
Status: new | Component: Core (Mail)
Version: 6.0 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+---------------------------------------
Most django.core.mail APIs take a `fail_silently` parameter which is
intended to suppress errors during sending, as well as a `connection`
parameter to provide a specific EmailBackend instance for sending. When
`connection` is specified, `fail_silently` is ignored.

To reproduce, configure your email settings to cause an error (e.g.,
`EMAIL_HOST="not.a.real.host"`) and:
{{{#!python
from django.core.mail import get_connection, send_mail

send_mail("subject", "body", None, ["t...@example.com"])
# Correct behavior: raises socket.gaierror: [Errno 8] nodename nor
servname provided, or not known

send_mail("subject", "body", None, ["t...@example.com"], fail_silently=True)
# Correct behavior: returns 0 messages sent, doesn't raise an error

send_mail("subject", "body", None, ["t...@example.com"], fail_silently=True,
connection=get_connection())
# Bug: despite fail_silently=True, raises socket.gaierror
}}}

A similar problem exists with the `auth_user` and `auth_password` params
to `send_mail()` and `send_mass_mail()`, which are also silently ignored
when a `connection` is provided.

There is no safe way to set any of these options on a connection
(EmailBackend instance) once it has been constructed. The correct way to
achieve the desired behavior is move `fail_silently` and the other params
into `get_connection()`:

{{{#!python
send_mail("subject", "body", None, ["t...@example.com"],
connection=get_connection(fail_silently=True, username="auth_user",
password="auth_password"))
}}}


**Suggested fix**

Django's email APIs should handle `fail_silently`, `auth_user` and
`auth_password` params as an error when `connection` is also provided.
This will involve:
- Changing the default from `fail_silently=False` to `fail_silently=None`
to be able to distinguish the cases. (Don't forget EmailMessage.send().)
- Raising a TypeError when `connection is not None and fail_silently is
not None`. Something like "fail_silently cannot be used with a connection.
(Pass fail_silently to get_connection() instead.)"
- Converting fail_silently==None to False where the high level APIs call
get_connection()
- Issuing similar error messages for `auth_user` and `auth_password`
(which already default to None)
- Updating tests to cover the new behavior
--
Ticket URL: <https://code.djangoproject.com/ticket/36894>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 31, 2026, 3:06:37 AMJan 31
to django-...@googlegroups.com
#36894: Email fail_silently, auth_user, auth_password are ignored when connection
param provided
------------------------------+----------------------------------------
Reporter: Mike Edmunds | Owner: Kundan Yadav
Type: Bug | Status: assigned
Component: Core (Mail) | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+----------------------------------------
Changes (by Kundan Yadav):

* owner: (none) => Kundan Yadav
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/36894#comment:1>

Django

unread,
Feb 2, 2026, 1:37:54 PMFeb 2
to django-...@googlegroups.com
#36894: Email fail_silently, auth_user, auth_password are ignored when connection
param provided
-------------------------------------+-------------------------------------
Reporter: Mike Edmunds | Owner: Kundan
Type: | Yadav
Cleanup/optimization | Status: assigned
Component: Core (Mail) | Version: 6.0
Severity: Normal | Resolution:
Keywords: email fail_silently | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Natalia Bidart):

* keywords: => email fail_silently
* stage: Unreviewed => Accepted
* type: Bug => Cleanup/optimization

Comment:

Thank you Mike for this ticket! I agree with your rationale, but
personally I see this as a cleanup rather than a bug. I believe the was a
lacking of being explicit in the docs that if a connection is given, the
other connection-related params are ignored.

I would also include in your "Suggested fix" list to improve the docs.
--
Ticket URL: <https://code.djangoproject.com/ticket/36894#comment:2>

Django

unread,
Feb 2, 2026, 3:07:27 PMFeb 2
to django-...@googlegroups.com
#36894: Email fail_silently, auth_user, auth_password are ignored when connection
param provided
-------------------------------------+-------------------------------------
Reporter: Mike Edmunds | Owner: Kundan
Type: | Yadav
Cleanup/optimization | Status: assigned
Component: Core (Mail) | Version: 6.0
Severity: Normal | Resolution:
Keywords: email fail_silently | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mike Edmunds):

* easy: 0 => 1


Old description:
New description:
- Updating docs to note the changed behavior (params that had been
silently ignored with `connection` will now raise an error)

--
Comment:

(Edited "suggested fix" to include adding versionchanged notes in relevant
docs.)
--
Ticket URL: <https://code.djangoproject.com/ticket/36894#comment:3>

Django

unread,
Feb 5, 2026, 8:05:14 AMFeb 5
to django-...@googlegroups.com
#36894: Email fail_silently, auth_user, auth_password are ignored when connection
param provided
--------------------------------------+------------------------------------
Reporter: Mike Edmunds | Owner: (none)
Type: Cleanup/optimization | Status: new
Component: Core (Mail) | Version: 6.0
Severity: Normal | Resolution:
Keywords: email fail_silently | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Kundan Yadav):

* owner: Kundan Yadav => (none)
* status: assigned => new

--
Ticket URL: <https://code.djangoproject.com/ticket/36894#comment:4>

Django

unread,
Feb 5, 2026, 8:09:16 AMFeb 5
to django-...@googlegroups.com
#36894: Email fail_silently, auth_user, auth_password are ignored when connection
param provided
-------------------------------------+-------------------------------------
Reporter: Mike Edmunds | Owner: Kundan
Type: | Yadav
Cleanup/optimization | Status: assigned
Component: Core (Mail) | Version: 6.0
Severity: Normal | Resolution:
Keywords: email fail_silently | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Kundan Yadav):

* owner: (none) => Kundan Yadav
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/36894#comment:5>

Django

unread,
Feb 5, 2026, 8:06:33 PMFeb 5
to django-...@googlegroups.com
#36894: Email fail_silently, auth_user, auth_password are ignored when connection
param provided
-------------------------------------+-------------------------------------
Reporter: Mike Edmunds | Owner: Kundan
Type: | Yadav
Cleanup/optimization | Status: assigned
Component: Core (Mail) | Version: 6.0
Severity: Normal | Resolution:
Keywords: email fail_silently | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Mike Edmunds):

Note that django.utils.log.AdminEmailHandler provides `fail_silently=True`
to both `get_connection()` and `mail_admins()`. The latter is redundant
and will result in an error once this change is implemented (so will need
to be removed).
--
Ticket URL: <https://code.djangoproject.com/ticket/36894#comment:6>

Django

unread,
Feb 10, 2026, 1:00:10 AMFeb 10
to django-...@googlegroups.com
#36894: Email fail_silently, auth_user, auth_password are ignored when connection
param provided
-------------------------------------+-------------------------------------
Reporter: Mike Edmunds | Owner: Praful
Type: | Gulani
Cleanup/optimization | Status: assigned
Component: Core (Mail) | Version: 6.0
Severity: Normal | Resolution:
Keywords: email fail_silently | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Praful Gulani):

* owner: Kundan Yadav => Praful Gulani

--
Ticket URL: <https://code.djangoproject.com/ticket/36894#comment:7>

Django

unread,
Feb 12, 2026, 11:04:08 AMFeb 12
to django-...@googlegroups.com
#36894: Email fail_silently, auth_user, auth_password are ignored when connection
param provided
-------------------------------------+-------------------------------------
Reporter: Mike Edmunds | Owner: Praful
Type: | Gulani
Cleanup/optimization | Status: assigned
Component: Core (Mail) | Version: 6.0
Severity: Normal | Resolution:
Keywords: email fail_silently | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Praful Gulani):

* has_patch: 0 => 1

Comment:

[https://github.com/django/django/pull/20685 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/36894#comment:8>

Django

unread,
Feb 12, 2026, 3:13:14 PMFeb 12
to django-...@googlegroups.com
#36894: Email fail_silently, auth_user, auth_password are ignored when connection
param provided
-------------------------------------+-------------------------------------
Reporter: Mike Edmunds | Owner: Praful
Type: | Gulani
Cleanup/optimization | Status: assigned
Component: Core (Mail) | Version: 6.0
Severity: Normal | Resolution:
Keywords: email fail_silently | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mike Edmunds):

* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36894#comment:9>

Django

unread,
Feb 14, 2026, 4:25:49 AMFeb 14
to django-...@googlegroups.com
#36894: Email fail_silently, auth_user, auth_password are ignored when connection
param provided
-------------------------------------+-------------------------------------
Reporter: Mike Edmunds | Owner: Praful
Type: | Gulani
Cleanup/optimization | Status: assigned
Component: Core (Mail) | Version: 6.0
Severity: Normal | Resolution:
Keywords: email fail_silently | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Praful Gulani):

* needs_better_patch: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/36894#comment:10>

Django

unread,
Feb 14, 2026, 1:20:58 PMFeb 14
to django-...@googlegroups.com
#36894: Email fail_silently, auth_user, auth_password are ignored when connection
param provided
-------------------------------------+-------------------------------------
Reporter: Mike Edmunds | Owner: Praful
Type: | Gulani
Cleanup/optimization | Status: assigned
Component: Core (Mail) | Version: 6.0
Severity: Normal | Resolution:
Keywords: email fail_silently | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mike Edmunds):

* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/36894#comment:11>

Django

unread,
Feb 14, 2026, 8:27:35 PMFeb 14
to django-...@googlegroups.com
#36894: Email fail_silently, auth_user, auth_password are ignored when connection
param provided
-------------------------------------+-------------------------------------
Reporter: Mike Edmunds | Owner: Praful
Type: | Gulani
Cleanup/optimization | Status: assigned
Component: Core (Mail) | Version: 6.0
Severity: Normal | Resolution:
Keywords: email fail_silently | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Praful Gulani):

* needs_better_patch: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/36894#comment:12>

Django

unread,
Feb 15, 2026, 2:17:36 PMFeb 15
to django-...@googlegroups.com
#36894: Email fail_silently, auth_user, auth_password are ignored when connection
param provided
-------------------------------------+-------------------------------------
Reporter: Mike Edmunds | Owner: Praful
Type: | Gulani
Cleanup/optimization | Status: assigned
Component: Core (Mail) | Version: 6.0
Severity: Normal | Resolution:
Keywords: email fail_silently | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mike Edmunds):

* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/36894#comment:13>

Django

unread,
Mar 13, 2026, 1:22:09 PMMar 13
to django-...@googlegroups.com
#36894: Email fail_silently, auth_user, auth_password are ignored when connection
param provided
-------------------------------------+-------------------------------------
Reporter: Mike Edmunds | Owner: Praful
Type: | Gulani
Cleanup/optimization | Status: assigned
Component: Core (Mail) | Version: 6.0
Severity: Normal | Resolution:
Keywords: email fail_silently | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* needs_docs: 0 => 1
* stage: Ready for checkin => Accepted

Comment:

Requested a simple entry in the release notes, and added a question about
whether explicit `fail_silently=False` truly needs to raise.
--
Ticket URL: <https://code.djangoproject.com/ticket/36894#comment:14>

Django

unread,
Mar 16, 2026, 12:01:34 PMMar 16
to django-...@googlegroups.com
#36894: Email fail_silently, auth_user, auth_password are ignored when connection
param provided
-------------------------------------+-------------------------------------
Reporter: Mike Edmunds | Owner: Praful
Type: | Gulani
Cleanup/optimization | Status: assigned
Component: Core (Mail) | Version: 6.0
Severity: Normal | Resolution:
Keywords: email fail_silently | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* needs_docs: 1 => 0
* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/36894#comment:15>

Django

unread,
Mar 16, 2026, 12:52:17 PMMar 16
to django-...@googlegroups.com
#36894: Email fail_silently, auth_user, auth_password are ignored when connection
param provided
-------------------------------------+-------------------------------------
Reporter: Mike Edmunds | Owner: Praful
Type: | Gulani
Cleanup/optimization | Status: closed
Component: Core (Mail) | Version: 6.0
Severity: Normal | Resolution: fixed
Keywords: email fail_silently | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls <jacobtylerwalls@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"2333d56696141303000986a16553205ece993c67" 2333d566]:
{{{#!CommitTicketReference repository=""
revision="2333d56696141303000986a16553205ece993c67"
Fixed #36894 -- Added TypeError for conflicting arguments in mail APIs.

A TypeError is now raised if fail_silently=True, auth_user, or
auth_password
are provided along a connection.

Updated AdminEmailHandler in django.utils.log to remove redundant
fail_silently=True.

Thanks Mike Edmunds for the report and Jacob Tyler Walls for the review.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36894#comment:16>
Reply all
Reply to author
Forward
0 new messages