mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #22561 -- Prevented too long lines in email messages
Thanks NotSqrt for the excellent report and Tim Graham for the review.
This commit is contained in:
@@ -639,6 +639,22 @@ class BaseEmailBackendTests(HeadersCheckMixin, object):
|
||||
self.assertEqual(message["subject"], '=?utf-8?q?Ch=C3=A8re_maman?=')
|
||||
self.assertEqual(force_text(message.get_payload(decode=True)), 'Je t\'aime très fort')
|
||||
|
||||
def test_send_long_lines(self):
|
||||
"""
|
||||
Email line length is limited to 998 chars by the RFC:
|
||||
https://tools.ietf.org/html/rfc5322#section-2.1.1
|
||||
Message body containing longer lines are converted to Quoted-Printable
|
||||
to avoid having to insert newlines, which could be hairy to do properly.
|
||||
"""
|
||||
email = EmailMessage('Subject', "Comment ça va? " * 100, 'from@example.com', ['to@example.com'])
|
||||
email.send()
|
||||
message = self.get_the_message()
|
||||
self.assertMessageHasHeaders(message, {
|
||||
('MIME-Version', '1.0'),
|
||||
('Content-Type', 'text/plain; charset="utf-8"'),
|
||||
('Content-Transfer-Encoding', 'quoted-printable'),
|
||||
})
|
||||
|
||||
def test_send_many(self):
|
||||
email1 = EmailMessage('Subject', 'Content1', 'from@example.com', ['to@example.com'])
|
||||
email2 = EmailMessage('Subject', 'Content2', 'from@example.com', ['to@example.com'])
|
||||
|
||||
Reference in New Issue
Block a user