﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
35581	Upgrade django.core.mail to use Python's modern email API	Mike Edmunds	Mike Edmunds	"django.core.mail.EmailMessage currently uses [https://docs.python.org/3/library/email.html#:~:text=email%3A%20Examples-,Legacy%20API%3A,-email.message.Message Python's ""legacy"" email API]. Updating that code to Python's newer [https://docs.python.org/3/library/email.html#:~:text=modern%20(unicode%20friendly)%20API%20of%20the%20email%20package ""modern"" email API] would fix bugs and substantially simplify it.

[https://groups.google.com/g/django-developers/c/2zf9GQtjdIk django-developers discussion]

The update should be mostly transparent for users of Django's documented mail APIs, but will rework the internals of django.core.mail.message in ways that may require changes to some third-party email backends and other code that borrows undocumented (but popular) functions from that module. In addition, parts of Django's mail test suite will need reworking to avoid dependence on legacy implementation specifics.

Some relevant posts from django-developers:
* [https://groups.google.com/g/django-developers/c/2zf9GQtjdIk/m/GWjimue9FAAJ Background and rationale] for switching to Python's modern email API
* [https://groups.google.com/g/django-developers/c/2zf9GQtjdIk/m/RcvARzp9BAAJ Proposed implementation details] (some of these were modified in later discussion—in particular, we [https://groups.google.com/g/django-developers/c/2zf9GQtjdIk/m/4S7UekG4BAAJ don't expect to combine EmailMultiAlternatives into EmailMessage] as part of this ticket, and we [https://groups.google.com/g/django-developers/c/2zf9GQtjdIk/m/LcBfqfizAAAJ won't deprecate MIMEBase attachments] just yet)
* [https://groups.google.com/g/django-developers/c/2zf9GQtjdIk/m/mKqz2OKtAAAJ Deprecation details] for the documented BadHeaderError, SafeMIMEText and SafeMIMEMultipart, and the undocumented forbid_multi_line_headers() and sanitize_address()
"	Cleanup/optimization	closed	Core (Mail)	dev	Normal	fixed	email, compat32	bcail	Ready for checkin	1	0	0	0	0	0
