mirror of
https://github.com/django/django.git
synced 2025-07-07 21:35:15 +00:00
![]() 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. |
||
---|---|---|
.. | ||
attachments | ||
__init__.py | ||
custombackend.py | ||
test_sendtestemail.py | ||
tests.py |