Fixed #18861 -- Triggered message validation with locmem email backend
Thanks Bruno Renié for the report and the initial patch.
This commit is contained in:
parent
0ab8c58ca8
commit
8599f64e54
|
@ -20,5 +20,7 @@ class EmailBackend(BaseEmailBackend):
|
||||||
|
|
||||||
def send_messages(self, messages):
|
def send_messages(self, messages):
|
||||||
"""Redirect messages to the dummy outbox"""
|
"""Redirect messages to the dummy outbox"""
|
||||||
|
for message in messages: # .message() triggers header validation
|
||||||
|
message.message()
|
||||||
mail.outbox.extend(messages)
|
mail.outbox.extend(messages)
|
||||||
return len(messages)
|
return len(messages)
|
||||||
|
|
|
@ -498,6 +498,11 @@ class LocmemBackendTests(BaseEmailBackendTests, TestCase):
|
||||||
connection2.send_messages([email])
|
connection2.send_messages([email])
|
||||||
self.assertEqual(len(mail.outbox), 2)
|
self.assertEqual(len(mail.outbox), 2)
|
||||||
|
|
||||||
|
def test_validate_multiline_headers(self):
|
||||||
|
# Ticket #18861 - Validate emails when using the locmem backend
|
||||||
|
with self.assertRaises(BadHeaderError):
|
||||||
|
send_mail('Subject\nMultiline', 'Content', 'from@example.com', ['to@example.com'])
|
||||||
|
|
||||||
|
|
||||||
class FileBackendTests(BaseEmailBackendTests, TestCase):
|
class FileBackendTests(BaseEmailBackendTests, TestCase):
|
||||||
email_backend = 'django.core.mail.backends.filebased.EmailBackend'
|
email_backend = 'django.core.mail.backends.filebased.EmailBackend'
|
||||||
|
|
Loading…
Reference in New Issue