Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #18861 -- Triggered message validation with locmem email backend

Thanks Bruno Renié for the report and the initial patch.
  • Loading branch information...
commit 8599f64e54adfb32ee6550ed7a6ec9944034d978 1 parent 0ab8c58
@claudep claudep authored
View
2  django/core/mail/backends/locmem.py
@@ -20,5 +20,7 @@ def __init__(self, *args, **kwargs):
def send_messages(self, messages):
"""Redirect messages to the dummy outbox"""
+ for message in messages: # .message() triggers header validation
+ message.message()
mail.outbox.extend(messages)
return len(messages)
View
5 tests/regressiontests/mail/tests.py
@@ -498,6 +498,11 @@ def test_locmem_shared_messages(self):
connection2.send_messages([email])
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):
email_backend = 'django.core.mail.backends.filebased.EmailBackend'
Please sign in to comment.
Something went wrong with that request. Please try again.