[Django] #27210: SMTPBackend does not honor fail_silently=True when receiving a socket level connection error

12 views
Skip to first unread message

Django

unread,
Sep 12, 2016, 8:45:04 AM9/12/16
to django-...@googlegroups.com
#27210: SMTPBackend does not honor fail_silently=True when receiving a socket level
connection error
-----------------------------+--------------------
Reporter: whyscream | Owner: nobody
Type: Bug | Status: new
Component: Core (Mail) | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+--------------------
The Python SMTPlib does not wrap connection errors that occur on socket
level while setting up a connection. That means that Django needs to catch
socket errors too (@here:
https://github.com/django/django/blob/master/django/core/mail/backends/smtp.py#L73)
when `fail_silently` is enabled and the connection fails with a
`socket.error` (f.i.: Connection refused) or `socket.timeout` (f.i.
Connection timed out).

I tested this by setting up a django 1.10 with following settings:
{{{
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'localhost'
EMAIL_PORT = 10587 # nothing is listening here!
}}}

Then I copied the core admincommand `sendtestemail.py` to one of my apps,
and modified
https://github.com/django/django/blob/master/django/core/management/commands/sendtestemail.py#L34
to set `fail_silently=True`. This should yield no error, but it ends in a
Traceback.

Original problem of this issue for me was the
`utils.log.AdminEmailHandler` that uses this feature. I can try to create
some test cases for this issue when the issue is deemed valid.

--
Ticket URL: <https://code.djangoproject.com/ticket/27210>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 12, 2016, 9:07:07 AM9/12/16
to django-...@googlegroups.com
#27210: logging EmailBackend does not honor fail_silently=True when receiving a
socket level connection error
-----------------------------+--------------------------------------

Reporter: whyscream | Owner: nobody
Type: Bug | Status: new
Component: Core (Mail) | Version: master
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 whyscream):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


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

Django

unread,
Sep 12, 2016, 10:45:00 AM9/12/16
to django-...@googlegroups.com
#27210: smtp EmailBackend doesn't honor fail_silently=True when receiving a socket
level connection error
-----------------------------+------------------------------------

Reporter: whyscream | Owner: nobody
Type: Bug | Status: new
Component: Core (Mail) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------+------------------------------------
Changes (by timgraham):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/27210#comment:2>

Django

unread,
Sep 22, 2016, 9:44:57 AM9/22/16
to django-...@googlegroups.com
#27210: smtp EmailBackend doesn't honor fail_silently=True when receiving a socket
level connection error
-------------------------------------+-------------------------------------
Reporter: Tom Hendrikx | Owner: Vesteinn
| Snaebjarnarson
Type: Bug | Status: assigned

Component: Core (Mail) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Vesteinn Snaebjarnarson):

* owner: nobody => Vesteinn Snaebjarnarson
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/27210#comment:3>

Django

unread,
Sep 22, 2016, 10:22:55 AM9/22/16
to django-...@googlegroups.com
#27210: smtp EmailBackend doesn't honor fail_silently=True when receiving a socket
level connection error

-------------------------------------+-------------------------------------
Reporter: Tom Hendrikx | Owner: Vesteinn
| Snaebjarnarson
Type: Bug | Status: assigned
Component: Core (Mail) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Vesteinn Snaebjarnarson):

* has_patch: 0 => 1


Comment:

See pull request at https://github.com/django/django/pull/7281

Added ConnectionError to the exception tuple for the SMTPBackend with
tests.

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

Django

unread,
Sep 22, 2016, 7:38:05 PM9/22/16
to django-...@googlegroups.com
#27210: smtp EmailBackend doesn't honor fail_silently=True when receiving a socket
level connection error

-------------------------------------+-------------------------------------
Reporter: Tom Hendrikx | Owner: Vesteinn
| Snaebjarnarson
Type: Bug | Status: assigned
Component: Core (Mail) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* needs_better_patch: 0 => 1


Comment:

Please uncheck "Patch needs improvement" when review comments are
addressed and tests are passing.

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

Django

unread,
Sep 27, 2016, 2:35:15 PM9/27/16
to django-...@googlegroups.com
#27210: smtp EmailBackend doesn't honor fail_silently=True when receiving a socket
level connection error

-------------------------------------+-------------------------------------
Reporter: Tom Hendrikx | Owner: Vesteinn
| Snaebjarnarson
Type: Bug | Status: closed

Component: Core (Mail) | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

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


Comment:

In [changeset:"602bffe7585c6b61f3d9badf21f84c1eb445d58f" 602bffe7]:
{{{
#!CommitTicketReference repository=""
revision="602bffe7585c6b61f3d9badf21f84c1eb445d58f"
Fixed #27210 -- Allowed SMTPBackend to fail silently on a socket
connection error.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27210#comment:6>

Django

unread,
Sep 30, 2016, 12:23:04 PM9/30/16
to django-...@googlegroups.com
#27210: smtp EmailBackend doesn't honor fail_silently=True when receiving a socket
level connection error

-------------------------------------+-------------------------------------
Reporter: Tom Hendrikx | Owner: Vesteinn
| Snaebjarnarson
Type: Bug | Status: closed
Component: Core (Mail) | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by GitHub <noreply@…>):

In [changeset:"f6fe8ecc10a3d88470e25fe6ebc61122154653f0" f6fe8ecc]:
{{{
#!CommitTicketReference repository=""
revision="f6fe8ecc10a3d88470e25fe6ebc61122154653f0"
Refs #27210 -- Fixed isolation of test_fail_silently_on_connection_error.

The test wouldn't pass if a mail server is running on the system.
}}}

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

Reply all
Reply to author
Forward
0 new messages