#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:
> 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" <[email protected]>',
> [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 <[email protected]>',
> [Cfg.EMAIL_SUPPORT],
> fail_silently=True,
> )
> }}}
>
> Then the from field in gmail is:
> {{{
> 'Notifications' via support <[email protected]>
> }}}
>
> 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 `[email protected]` not `[email protected]`
>
> This is my settings.py:
> {{{
> SERVER_EMAIL = f'[email protected]' # The reply to
> DEFAULT_FROM_EMAIL = [email protected]'
> ADMINS = [('Support', '[email protected]')]
> 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.
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
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" <[email protected]>',
[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 <[email protected]>',
[Cfg.EMAIL_SUPPORT],
fail_silently=True,
)
}}}
Then the from field in gmail is:
{{{
'Notifications' via support <[email protected]>
}}}
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 `[email protected]` not `[email protected]`
This is my settings.py:
{{{
SERVER_EMAIL = f'[email protected]' # The reply to
DEFAULT_FROM_EMAIL = [email protected]'
ADMINS = [('Support', '[email protected]')]
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#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/068.dc5030c857f30b4bde77a59e56c8e8b3%40djangoproject.com.