summaryrefslogtreecommitdiff
path: root/django/core/mail/backends/smtp.py
AgeCommit message (Collapse)Author
2025-07-25Fixed #35581 -- Updated django.core.mail to Python's modern email API.Mike Edmunds
- Changed EmailMessage.message() to construct a "modern email API" email.message.EmailMessage and added policy keyword arg. - Added support for modern MIMEPart objects in EmailMessage.attach() (and EmailMessage constructor, EmailMessage.attachments list). - Updated SMTP EmailBackend to use modern email.policy.SMTP. Deprecated: - Attaching MIMEBase objects (replace with MIMEPart) - BadHeaderError (modern email uses ValueError) - SafeMIMEText, SafeMIMEMultipart (unnecessary for modern email) - django.core.mail.forbid_multi_line_headers() (undocumented, but exposed via `__all__` and in wide use) - django.core.mail.message.sanitize_address() (undocumented, but in wide use) Removed without deprecation (all undocumented): - EmailMessage.mixed_subtype - EmailMultiAlternatives.alternative_subtype - Support for setting (undocumented) EmailMessage.encoding property to a legacy email.charset.Charset object Related changes: - Dropped tests for incorrect RFC 2047 encoding of non-ASCII email address localparts. This is specifically prohibited by RFC 2047, and not supported by any known MTA or email client. (Python still mis-applies encoded-word to non-ASCII localparts, but it is a bug that may be fixed in the future.) - Added tests that try to discourage using Python's legacy email APIs in future updates to django.core.mail.
2024-01-26Applied Black's 2024 stable style.Mariusz Felisiak
https://github.com/psf/black/releases/tag/24.1.0
2023-03-14Improved connection clean-up for SMTP backend.Carlton Gibson
2023-03-06Fixed #34386 -- Made SMTP backend load default system root CA certificates ↵Dmitriy Sintsov
by default. Regression in 2848e5d0ce5cf3c31fe87525536093b21d570f69.
2022-11-16Refs #34118 -- Used smtplib's context parameter instead of keyfile and certfile.Mariusz Felisiak
keyfile and certfile parameters were removed in Python 3.12, see https://github.com/python/cpython/commit/ef0e72b31d22f780d3a165d7d0471806061fe380
2022-02-07Refs #33476 -- Reformatted code with Black.django-bot
2019-01-28Fixed #30137 -- Replaced OSError aliases with the canonical OSError.Jon Dufresne
Used more specific errors (e.g. FileExistsError) as appropriate.
2018-12-26Fixed #30058 -- Made SMTP EmailBackend.send_messages() return 0 for ↵Denis Stebunov
empty/error cases.
2017-02-21Refs #27656 -- Updated django.core docstring verbs according to PEP 257.Anton Samarchyan
2017-01-25Refs #23919 -- Replaced super(ClassName, self) with super().chillaranand
2017-01-20Refs #23919 -- Removed unneeded force_str callsClaude Paroz
2016-12-23Refs #26487 -- Removed unneeded ehlo() calls in SMTP backend.Tim Graham
starttls(), login(), and other connection methods already call the method as needed.
2016-10-05Removed unused variable in django/core/mail/backends/smtp.py.Tim Graham
2016-09-27Fixed #27210 -- Allowed SMTPBackend to fail silently on a socket connection ↵Vesteinn Snaebjarnarson
error.
2016-09-21Fixed #26210 -- Prevented SMTP backend from trying to send mail after a ↵levental
connection failure.
2016-08-31Fixed #27131 -- Passed proper string type to SMTP connection loginClaude Paroz
Passing an Unicode string on Python 2 was crashing the connection. Thanks slavugan@gmail.com for the report, and Tim Graham for the review.
2016-05-06Fixed #25986 -- Fixed crash sending email with non-ASCII in local part of ↵Sergei Maertens
the address. On Python 3, sending emails failed for addresses containing non-ASCII characters due to the usage of the legacy Python email.utils.formataddr() function. This is fixed by using the proper Address object on Python 3.
2015-02-06Sorted imports with isort; refs #23860.Tim Graham
2014-10-12Fixed #23063 -- Convert \n and \r to \r\n when using the SMTP backend as per ↵Florian Apolloner
RFC.
2014-09-13Fixed #23461 -- Added EMAIL_TIMEOUT settingJosé Padilla
2014-09-10Fixed #20743 -- Added support for keyfile/certfile in SMTP connections.Andi Albrecht
Thanks jwmayfield, serg.partizan, and Wojciech Banaś for work on the patch.
2014-01-12Undelete the `return True` removed in 4e0a2fe.Marc Tamlyn
This is quite important otherwise we don't close our connections to the SMTP server.
2013-12-28Introduced as_bytes for SafeMIMEText (and other SafeMIME-classes).Florian Apolloner
This is to provide a consistent interface (namely bytes) for the smtp backend which after all sends bytes over the wire; encoding with as_string yields different results since mails as unicode are not really specified. as_string stays for backwardscompatibilty mostly and some debug outputs. But keep in mind that the output doesn't match as_bytes!
2013-10-25Undelete the login() call inadvertantly removed in 4e0a2fe59cClaude Paroz
Refs #21271.
2013-10-24Fixed #21271 -- Added timeout parameter to SMTP EmailBackend.SusanTan
Thanks Tobias McNulty and Tim Graham for discussions and code review. Thanks Andre Cruz the suggestion and initial patch.
2013-10-05Fixed #21189: Cleaned up usage of bare except clauses.Baptiste Mispelon
Thanks to berkerpeksag for the report and to claudep for the review.
2013-07-11Fixed #17471 -- Added smtplib.SMTP_SSL connection option for SMTP backendClaude Paroz
Thanks dj.facebook at gmail.com for the report and initial patch and Areski Belaid and senko for improvements.
2013-01-03Replaced deprecated sslerror by ssl.SSLErrorClaude Paroz
The exact conditions on which this exception is raised are not known, but this replacement is the best guess we can do at this point.
2013-01-03Fixed #19382 -- Stopped smtp backend raising exception when already closedClaude Paroz
Thanks Sebastian Noack for the report and the initial patch.
2013-01-03Fixed #19134 -- Allowed closing smtp backend when the server is stoppedClaude Paroz
Thanks Sebastian Noack for the report and the initial patch.
2012-11-14Fixed #19186 -- Fixed sending mail with unicode content on Python 3Claude Paroz
Thanks alex_po for the report and Luke Plant for the analysis.
2012-06-23Switch to using context managers for acquiring and releasing locks.Alex Gaynor
2011-07-03Fixed #15750 -- Handle empty mail server credentials gracefully. Thanks, ↵Jannis Leidel
LeandroSouza and bedmondmark. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16494 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-01-15Fixed #15042 -- Ensured that email addresses without a domain can still be ↵Russell Keith-Magee
mail recipients. Patch also improves the IDN handling introduced by r15006, and refactors the test suite to ensure even feature coverage. Thanks to net147 for the report, and to Łukasz Rekucki for the awesome patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@15211 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-12-21Fixed #14301 -- Further refine changes made in r14216 to support non-ASCII ↵Jannis Leidel
characters in email addresses. Thanks, Claude Peroz and Andi Albrecht. git-svn-id: http://code.djangoproject.com/svn/django/trunk@15006 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-11-04Fixed #11849 -- Corrected handling of use_tls in the SMTP mail handler. ↵Russell Keith-Magee
Thanks to aromano for the report. git-svn-id: http://code.djangoproject.com/svn/django/trunk@11714 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-11-03Fixed #10355 -- Added an API for pluggable e-mail backends.Russell Keith-Magee
Thanks to Andi Albrecht for his work on this patch, and to everyone else that contributed during design and development. git-svn-id: http://code.djangoproject.com/svn/django/trunk@11709 bcc190cf-cafb-0310-a4f2-bffc1f526a37