[Django] #33498: Email TO: field unusual behavior of changing the input, can lead to errors

11 views
Skip to first unread message

Django

unread,
Feb 6, 2022, 4:53:36 PM2/6/22
to django-...@googlegroups.com
#33498: Email TO: field unusual behavior of changing the input, can lead to errors
-----------------------------------------+------------------------
Reporter: Michael | Owner: nobody
Type: Uncategorized | Status: new
Component: Core (Mail) | Version: 4.0
Severity: Normal | Keywords: email
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
This code will generate a 500 error instead of sending an email about the
404 error (the problem is the TO field). It's a hard to error to find due
to no stack trace, had to binary search a lot of code to find it (cause it
works fine with console email backend (i.e during dev)):

{{{
from django.core.mail import send_mail

send_mail(
f'Suspicious file requested from {client_ip} for {path}',
f'Suspicious file requested from {client_ip}.\nURL:
{absolute_url}',
'"Notifications" <er...@example.com>',
[Cfg.EMAIL_SUPPORT],
fail_silently=True,
)
}}}

If one emoves the double quotes:
{{{
send_mail(
f'Suspicious file requested from {client_ip} for {path}',
f'Suspicious file requested from {client_ip}.\nURL:
{absolute_url}',
'Notifications <er...@example.com>',
[Cfg.EMAIL_SUPPORT],
fail_silently=True,
)
}}}

Then the from field in gmail is:
{{{
'Notifications' via support <sup...@example.com>
}}}

Which is not what it was set to. The person's name was set to
`Notifications` not `'Notifications' via support`, and the from email
address was set to `er...@example.com` not `sup...@example.com`

This is my settings.py:
{{{
SERVER_EMAIL = f'sup...@example.com' # The reply to
DEFAULT_FROM_EMAIL = some...@example.com'
ADMINS = [('Support', 'sup...@example.com')]
MANAGERS = ADMINS
EMAIL_SUBJECT_PREFIX = "Example Server: "
}}}

THe documentation says:
{{{
from_email: A string. If None, Django will use the value of the
DEFAULT_FROM_EMAIL setting.
}}}
It does not specify this unusual behavior.

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

Django

unread,
Feb 6, 2022, 5:00:08 PM2/6/22
to django-...@googlegroups.com
#33498: Email FROM: field unusual behavior of changing the input, can lead to
errors
-------------------------------+--------------------------------------

Reporter: Michael | Owner: nobody
Type: Uncategorized | Status: new
Component: Core (Mail) | Version: 4.0
Severity: Normal | Resolution:

Keywords: email | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Description changed by Michael:

Old description:

New description:

This code will generate a 500 error instead of sending an email about the

404 error (the problem is the FROM field). It's a hard to error to find

{{{
from django.core.mail import send_mail

--

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

Django

unread,
Feb 6, 2022, 5:30:00 PM2/6/22
to django-...@googlegroups.com
#33498: Email FROM: field unusual behavior of changing the input, can lead to
errors
-------------------------------+--------------------------------------
Reporter: Michael | Owner: nobody
Type: Uncategorized | Status: closed

Component: Core (Mail) | Version: 4.0
Severity: Normal | Resolution: needsinfo

Keywords: email | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Tim Graham):

* status: new => closed
* resolution: => needsinfo


Comment:

I'd guess this is a behavior of your mail server rather than Django. You
should debug further and reopen this ticket if you find that Django is at
fault.

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

Reply all
Reply to author
Forward
0 new messages