Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Claude Paroz authored
2  django/core/mail/backends/locmem.py
@@ -20,5 +20,7 @@ def __init__(self, *args, **kwargs):
20 20
 
21 21
     def send_messages(self, messages):
22 22
         """Redirect messages to the dummy outbox"""
  23
+        for message in messages:  # .message() triggers header validation
  24
+            message.message()
23 25
         mail.outbox.extend(messages)
24 26
         return len(messages)
5  tests/regressiontests/mail/tests.py
@@ -498,6 +498,11 @@ def test_locmem_shared_messages(self):
498 498
         connection2.send_messages([email])
499 499
         self.assertEqual(len(mail.outbox), 2)
500 500
 
  501
+    def test_validate_multiline_headers(self):
  502
+        # Ticket #18861 - Validate emails when using the locmem backend
  503
+        with self.assertRaises(BadHeaderError):
  504
+            send_mail('Subject\nMultiline', 'Content', 'from@example.com', ['to@example.com'])
  505
+
501 506
 
502 507
 class FileBackendTests(BaseEmailBackendTests, TestCase):
503 508
     email_backend = 'django.core.mail.backends.filebased.EmailBackend'

0 notes on commit 8599f64

Please sign in to comment.
Something went wrong with that request. Please try again.