diff options
| author | Claude Paroz <claude@2xlibre.net> | 2012-09-22 15:17:13 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2012-09-22 15:17:13 +0200 |
| commit | 8599f64e54adfb32ee6550ed7a6ec9944034d978 (patch) | |
| tree | 75a94bb8187baf66b61d33e455f72067749f5665 | |
| parent | 0ab8c58ca896643ea0bb0830a96274160d14cc69 (diff) | |
Fixed #18861 -- Triggered message validation with locmem email backend
Thanks Bruno ReniƩ for the report and the initial patch.
| -rw-r--r-- | django/core/mail/backends/locmem.py | 2 | ||||
| -rw-r--r-- | tests/regressiontests/mail/tests.py | 5 |
2 files changed, 7 insertions, 0 deletions
diff --git a/django/core/mail/backends/locmem.py b/django/core/mail/backends/locmem.py index 642bfc49fb..6826d09ee5 100644 --- a/django/core/mail/backends/locmem.py +++ b/django/core/mail/backends/locmem.py @@ -20,5 +20,7 @@ class EmailBackend(BaseEmailBackend): 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) diff --git a/tests/regressiontests/mail/tests.py b/tests/regressiontests/mail/tests.py index 3e9ae84650..33898cc1d5 100644 --- a/tests/regressiontests/mail/tests.py +++ b/tests/regressiontests/mail/tests.py @@ -498,6 +498,11 @@ class LocmemBackendTests(BaseEmailBackendTests, TestCase): 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' |
