It looks like a change added in python 3.11.9 #76511 Email parser creates a message object that can't be flattened has cuased a bug in django-ses.
If you send a message with unicode in the body you get the following error
File "/usr/local/lib/python3.11/site-packages/django/core/mail/message.py", line 169, in <genexpr>
len(line.encode()) > RFC5322_EMAIL_LINE_LENGTH_LIMIT
^^^^^^^^^^^^^
UnicodeEncodeError: 'utf-8' codec can't encode characters in position 3-5: surrogates not allowed
You can replicate this by updating the test_send_mail
def test_send_mail(self): settings.AWS_SES_CONFIGURATION_SET = None unicode_from_addr = 'Unicode Name óóóóóó <from@example.com>' send_mail('subject', 'body', unicode_from_addr, ['to@example.com']) message = self.outbox.pop() mail = email.message_from_string(smart_str(message['RawMessage']['Data'])) self.assertTrue('X-SES-CONFIGURAITON-SET' not in mail.keys()) self.assertEqual(mail['subject'], 'subject') self.assertEqual(mail['from'], self._rfc2047_helper(unicode_from_addr)) self.assertEqual(mail['to'], 'to@example.com') self.assertEqual(mail.get_payload(), 'body')to
def test_send_mail(self): settings.AWS_SES_CONFIGURATION_SET = None unicode_from_addr = 'Unicode Name óóóóóó <from@example.com>' - send_mail('subject', 'body', unicode_from_addr, ['to@example.com']) + send_mail('subject', 'body with unicode óóóóóó', unicode_from_addr, ['to@example.com']) message = self.outbox.pop() mail = email.message_from_string(smart_str(message['RawMessage']['Data'])) self.assertTrue('X-SES-CONFIGURAITON-SET' not in mail.keys()) self.assertEqual(mail['subject'], 'subject') self.assertEqual(mail['from'], self._rfc2047_helper(unicode_from_addr)) self.assertEqual(mail['to'], 'to@example.com') - self.assertEqual(mail.get_payload(), 'body') + self.assertEqual(mail.get_payload(), 'body with unicode óóóóóó')
This test will pass under python 3.11.8 but fail under 3.11.9
Bjornvdb, tudoramariei, danniel, kut, davidsarosi92 and 3 more
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4