Fixed #29140 -- Fixed EmailMessage crash when body is None.
This commit is contained in:
parent
548f78ba46
commit
2691ed7ba1
|
@ -231,7 +231,7 @@ class EmailMessage:
|
||||||
self.reply_to = []
|
self.reply_to = []
|
||||||
self.from_email = from_email or settings.DEFAULT_FROM_EMAIL
|
self.from_email = from_email or settings.DEFAULT_FROM_EMAIL
|
||||||
self.subject = subject
|
self.subject = subject
|
||||||
self.body = body
|
self.body = body or ''
|
||||||
self.attachments = []
|
self.attachments = []
|
||||||
if attachments:
|
if attachments:
|
||||||
for attachment in attachments:
|
for attachment in attachments:
|
||||||
|
|
|
@ -357,6 +357,11 @@ class MailTests(HeadersCheckMixin, SimpleTestCase):
|
||||||
msg.attach('example.txt', 'Text file content', 'text/plain')
|
msg.attach('example.txt', 'Text file content', 'text/plain')
|
||||||
self.assertIn(html_content, msg.message().as_string())
|
self.assertIn(html_content, msg.message().as_string())
|
||||||
|
|
||||||
|
def test_none_body(self):
|
||||||
|
msg = EmailMessage('subject', None, 'from@example.com', ['to@example.com'])
|
||||||
|
self.assertEqual(msg.body, '')
|
||||||
|
self.assertEqual(msg.message().get_payload(), '')
|
||||||
|
|
||||||
def test_encoding(self):
|
def test_encoding(self):
|
||||||
"""
|
"""
|
||||||
Regression for #12791 - Encode body correctly with other encodings
|
Regression for #12791 - Encode body correctly with other encodings
|
||||||
|
|
Loading…
Reference in New Issue