| Age | Commit message (Collapse) | Author |
|
Moved tests for specific email backends from tests/mail/tests.py
to test_backends.py to reduce file size and discourage adding
non-backend-specific tests to BaseEmailBackendTests.
|
|
Relocated BaseEmailBackendTests that are _not_ dependent on the email
backend.
- In general, moved test cases to EmailMessageTests or SendMailTests
as appropriate, and changed them to work with the testing outbox.
- Replaced BaseEmailBackendTests.test_send_verbose_name() with
EmailMessageTests.test_unicode_display_name_in_from_email().
(EmailMessageTests.test_address_header_handling() also partly covers
the behavior, as well as Python's own message serialization tests.)
- Removed BaseEmailBackendTests.test_message_cc_header(), which was
already covered by EmailMessageTests.test_cc*() (and Python's own
message serialization tests).
- Replaced BaseEmailBackendTests.test_idn_send() with
EmailMessageTests.test_idn_addresses() to cover from_email and cc.
(EmailMessageTests.test_address_header_handling() already covered to.)
- Removed BaseEmailBackendTests.test_recipient_without_domain(), which
was partly covered by EmailMessageTests.test_localpart_only_address().
Updated the latter to cover a localpart-only from_email.
- Updated docstrings and comments to clarify a few tests that _do_
depend on the email backend.
|
|
Replaced large MailTests class with smaller classes focused on
specific django.core.mail APIs:
- EmailMessageTests: covering EmailMessage and EmailMultiAlternatives
classes (the bulk of the former MailTests cases).
- SendMailTests, SendMassMailTests, MailAdminsAndManagersTests:
covering the function-based mail APIs.
- GetConnectionTests: covering get_connection().
- DeprecatedInternalsTests: covering deprecated internal methods used
in deprecated functionality.
- DummyBackendTests: covering the dummy EmailBackend.
In the process, moved the two cases from MailTimeZoneTests into the new
EmailMessageTests, as they related to EmailMessage Date headers.
|
|
Broke apart independent cases in mail tests using subTest() or separate
methods.
|
|
Django automatically substitutes the locmem EmailBackend during tests,
and SimpleTestCase empties mail.outbox before each test.
|
|
A TypeError is now raised if fail_silently=True, auth_user, or auth_password
are provided along a connection.
Updated AdminEmailHandler in django.utils.log to remove redundant
fail_silently=True.
Thanks Mike Edmunds for the report and Jacob Tyler Walls for the review.
|
|
https://github.com/psf/black/releases/tag/26.1.0
|
|
|
|
- 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.
|
|
EmailMessage is intended to support lazy strings in any header field
(via coercion to `str` in forbid_multi_line_headers() called from
SafeMIMEMessage/Text/Multipart.__setitem__).
|
|
Manually reformatted some comments and docstrings where autofix_w505.py
changed the meaning of the formatting.
|
|
Rewrapped long docstrings and block comments to 79 characters + newline
using script from https://github.com/medmunds/autofix-w505.
|
|
In public mail APIs, changed less frequently used parameters from
keyword-or-positional to keyword-only, emitting a warning during the
required deprecation period.
|
|
See python/cpython#128110.
|
|
Updated mail tests in preparation for migrating from Python's legacy
to modern email API. The updated tests will pass with either Python API,
and focus on desired outcomes (e.g., that a message with non-ASCII
content parses accurately at the receiving end) rather than specific
implementation details (e.g., where rfc2047 encoded-words are split).
In a few cases that are still implementation dependent, added comments
identifying behavior specific to the legacy email API and expected to
change under the modern one.
Added comments identifying tests that cover internal functions planned
for deprecation, and (where meaningful) added similar tests to verify
the equivalent behavior in non-deprecated features.
Removed obsolete tests left over from Python 2.
|
|
Fixed an inconsistency between EmailMessage.attach() and .attachments
when attaching bytes content with a text/* mimetype. The attach()
function decodes UTF-8 bytes if possible and otherwise changes the
mimetype to application/octet-stream to preserve the content's unknown
encoding (refs #27007). Providing equivalent content directly in
EmailMessage.attachments did not apply the same logic, leading
to an "AttributeError: 'bytes' object has no attribute 'encode'"
in SafeMIMEText.set_payload().
Updated EmailMessage._create_mime_attachment() to match attach()'s
handling for text/* mimetypes with bytes content. Updated test cases
to accurately cover behavior on both paths.
|
|
Regression in aba0e541caaa086f183197eaaca0ac20a730bbe4 and in
d5bebc1c26d4c0ec9eaa057aefc5b38649c0ba3b.
Thanks Florent Messa for the report, and Jake Howard and Claude
Paroz for the review.
|
|
Python's modern email API will force a trailing newline onto all text/*
bodies and attachments. Updated mail tests to include (and check for)
the newline while still using the legacy email API.
See https://github.com/python/cpython/issues/121515 which reasons that,
apart from artificial test cases, most text content already ends in a
newline. If it doesn't, adding one won't change the meaning.
|
|
Previously, the ADMINS and MANAGERS settings were lists of (name, address)
tuples (where the name had been unused). Deprecated use of tuples.
Updated settings value sanity checks, and changed from ValueError to
ImproperlyConfigured.
|
|
- Separated MailTests.test_connection_arg test cases.
- Expanded test cases for incorrect values of ADMINS/MANAGERS settings.
- Added test case verifying correct values of ADMINS/MANAGERS settings.
|
|
Content-Transfer-Encoding.
|
|
|
|
structure, bcc header, encoding and sending.
|
|
- Used modern email API (policy.default) for tests that reparse
generated messages, and switched to modern accessors where helpful.
- Split get_raw_attachments() helper out of get_decoded_attachments(),
and used modern iter_attachments() to avoid finding nested attachments
in attached message/* emails.
- Stopped using legacy parseaddr.
|
|
- Converted HeadersCheckMixin to MailTestsMixin for all shared helpers:
- Hoisted assertStartsWith() from BaseEmailBackendTests.
- Added matching assertEndsWith().
- Hoisted get_decoded_attachments() from MailTests.
- Improved failure reporting in assertMessageHasHeaders().
- Used unittest subTest() to improve handling of compound test cases.
- Replaced `assertTrue(test on string)` with custom assertions,
so that failure reporting is more informative than `True != False`.
|
|
|
|
This also removed a duplicate CTE case (that used to be distinct in Python 2).
|
|
This also removed send() calls, as this doesn't check the serialized content, and
the backend tests cover sending.
|
|
|
|
sending fails.
On successful submission of a password reset request, an email is sent
to the accounts known to the system. If sending this email fails (due to
email backend misconfiguration, service provider outage, network issues,
etc.), an attacker might exploit this by detecting which password reset
requests succeed and which ones generate a 500 error response.
Thanks to Thibaut Spriet for the report, and to Mariusz Felisiak, Adam
Johnson, and Sarah Boyce for the reviews.
|
|
attachments and alternatives.
|
|
Fixed a regression which would cause multiple To, Cc, and
Reply-To headers in the result of EmailMessage.message() if
values were supplied for both to/cc/reply_to and the
corresponding extra_headers fields.
Updated related tests to check the generated message() has
exactly one of each expected header using get_all().
Regression in b03d5002955256c4b3ed7cfae5150eb79c0eb97e.
|
|
|
|
EmailMultiAlternatives.alternatives to use namedtuples.
This makes it more descriptive to pull out the named fields.
|
|
There is no point in asserting Python error messages.
|
|
surrogate pairs.
Refs #33173, #34118 and #34900.
|
|
https://github.com/psf/black/releases/tag/24.1.0
|
|
|
|
|
|
|
|
backend.
|
|
empty strings.
|
|
- Updated references to RFC 1123 to RFC 5322
- Only partial as RFC 5322 sort of sub-references RFC 1123.
- Updated references to RFC 2388 to RFC 7578
- Except RFC 2388 Section 5.3 which has no equivalent.
- Updated references to RFC 2396 to RFC 3986
- Updated references to RFC 2616 to RFC 9110
- Updated references to RFC 3066 to RFC 5646
- Updated references to RFC 7230 to RFC 9112
- Updated references to RFC 7231 to RFC 9110
- Updated references to RFC 7232 to RFC 9110
- Updated references to RFC 7234 to RFC 9111
- Tidied up style of text when referring to RFC documents
|
|
|
|
|
|
|
|
asyncore and smtpd modules were deprecated in Python 3.10.
|
|
test_server_login() was a regression test for a crash when passing
Unicode strings to SMTP server using CRAM-MD5 method on Python 2.
Python 2 is no longer supported and test_server_login() passes even
without FakeSMTPChannel.smtp_AUTH() because
smtplib.SMTPAuthenticationError is raised when AUTH is not implemented.
|
|
Inspired by Adam Johnson talk on DjangoCon Europe 2021.
|
|
|