[Django] #36805: Use `None` as default value for `from_email` in `send_mail`-function

2 views
Skip to first unread message

Django

unread,
Dec 16, 2025, 9:59:35 AM12/16/25
to django-...@googlegroups.com
#36805: Use `None` as default value for `from_email` in `send_mail`-function
-------------------------------+-----------------------------------------
Reporter: Adrian Bürger | Type: Uncategorized
Status: new | Component: Core (Mail)
Version: 4.2 | 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
-------------------------------+-----------------------------------------
The docstring of the function `send_mail` states that

"If from_email is None, use the DEFAULT_FROM_EMAIL setting."

`from_email` is a required argument which would explicitly need to be set
to `None` so that `DEFAULT_FROM_EMAIL` is applied. However, other inputs
of this function such as `auth_user` and `auth_password` which have a
settings-value applied if they are `None`, are given a default value of
`None`. Therefore, I am not a sure whether this behavior is intended;
personally, I would expect `from_email` to have a default value of `None`.
Otherwise, users get an unexpected `TypeError: send_mail() missing 1
required positional argument: 'from_email'`.

I see this in Django 4.2 but still also in the current main branch on
GitHub.

Thank you for your consideration and for your work.
--
Ticket URL: <https://code.djangoproject.com/ticket/36805>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 16, 2025, 2:16:10 PM12/16/25
to django-...@googlegroups.com
#36805: Use `None` as default value for `from_email` in `send_mail`-function
-------------------------------+--------------------------------------
Reporter: Adrian Bürger | Owner: (none)
Type: Uncategorized | Status: closed
Component: Core (Mail) | Version: 4.2
Severity: Normal | Resolution: wontfix
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 Jacob Walls):

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

Comment:

Thanks for the ticket. If the proposal is to change the signature, it's
not worth breaking backward compatibility if it's not causing any issues.
--
Ticket URL: <https://code.djangoproject.com/ticket/36805#comment:1>

Django

unread,
Dec 22, 2025, 12:06:22 PM12/22/25
to django-...@googlegroups.com
#36805: Use `None` as default value for `from_email` in `send_mail`-function
-------------------------------+--------------------------------------
Reporter: Adrian Bürger | Owner: (none)
Type: Uncategorized | Status: closed
Component: Core (Mail) | Version: 4.2
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Comment (by Mike Edmunds):

Expanding on Jacob's response: `send_mail()` is one of the oldest
functions in Django and there's a lot of reluctance to change its
behavior. (You'll find comments in the code indicating its API is
"frozen.")

Django's `EmailMessage` class is a newer API that supports additional
features and more flexible usage. All of its parameters, including
`from_email`, are optional. So you can write:


{{{#!python
from django.core.mail import EmailMessage

EmailMessage(to=["t...@example.com"], subject="quick note").send()
}}}

to send a message using the `DEFAULT_FROM_EMAIL` with an empty body.
--
Ticket URL: <https://code.djangoproject.com/ticket/36805#comment:2>
Reply all
Reply to author
Forward
0 new messages