Ticket #18861: 18861.patch

File 18861.patch, 1.4 KB (added by Bruno Renié, 12 years ago)
  • django/core/mail/backends/locmem.py

    diff --git a/django/core/mail/backends/locmem.py b/django/core/mail/backends/locmem.py
    index 642bfc4..6826d09 100644
    a b class EmailBackend(BaseEmailBackend):  
    2020
    2121    def send_messages(self, messages):
    2222        """Redirect messages to the dummy outbox"""
     23        for message in messages:  # .message() triggers header validation
     24            message.message()
    2325        mail.outbox.extend(messages)
    2426        return len(messages)
  • tests/regressiontests/mail/tests.py

    diff --git a/tests/regressiontests/mail/tests.py b/tests/regressiontests/mail/tests.py
    index 3e9ae84..833a9e9 100644
    a b class MailTests(TestCase):  
    288288        self.assertEqual(len(connection.test_outbox), 1)
    289289        self.assertEqual(connection.test_outbox[0].subject, '[Django] Manager message')
    290290
     291    @override_settings(
     292        EMAIL_BACKEND='django.core.mail.backends.locmem.EmailBackend',
     293    )
     294    def test_validate_multiline_headers(self):
     295        # Ticket #18861 - Validate emails when using the locmem backend
     296        with self.assertRaises(BadHeaderError):
     297            send_mail('Subject\nMultiline', 'Content', 'from@example.com', ['to@example.com'])
     298
    291299    def test_dont_mangle_from_in_body(self):
    292300        # Regression for #13433 - Make sure that EmailMessage doesn't mangle
    293301        # 'From ' in message body.
Back to Top