@@ -318,6 +318,17 @@ def test_commas_in_subject(self):
318
318
sent_message = self .get_sent_message ()
319
319
self .assertEqual (sent_message ["Subject" ], self .message .subject )
320
320
321
+ def test_broken_address_header (self ):
322
+ # https://github.com/anymail/django-anymail/issues/369
323
+ self .message .to = ['"Người nhận a very very long, name" <to@example.com>' ]
324
+ self .message .cc = [
325
+ '"A véry long name with non-ASCII char and, comma" <cc@example.com>'
326
+ ]
327
+ self .message .send ()
328
+ sent_message = self .get_sent_message ()
329
+ self .assertEqual (sent_message ["To" ], self .message .to [0 ])
330
+ self .assertEqual (sent_message ["Cc" ], self .message .cc [0 ])
331
+
321
332
def test_no_cte_8bit (self ):
322
333
"""Anymail works around an Amazon SES bug that can corrupt non-ASCII bodies."""
323
334
# (see detailed comments in the backend code)
@@ -333,12 +344,14 @@ def test_no_cte_8bit(self):
333
344
self .message .attach (att )
334
345
335
346
self .message .send ()
336
- sent_message = self .get_sent_message ()
347
+ raw_mime = self .get_send_params ()["Content" ]["Raw" ]["Data" ]
348
+ self .assertTrue (raw_mime .isascii ()) # 7-bit clean
337
349
338
350
# Make sure none of the resulting parts use `Content-Transfer-Encoding: 8bit`.
339
351
# (Technically, either quoted-printable or base64 would be OK, but base64 text
340
352
# parts have a reputation for triggering spam filters, so just require
341
353
# quoted-printable for them.)
354
+ sent_message = self .get_sent_message ()
342
355
part_encodings = [
343
356
(part .get_content_type (), part ["Content-Transfer-Encoding" ])
344
357
for part in sent_message .walk ()
@@ -355,6 +368,21 @@ def test_no_cte_8bit(self):
355
368
],
356
369
)
357
370
371
+ def test_no_cte_8bit_root (self ):
372
+ # Same test as above, but with a non-multipart message using 8bit at root
373
+ self .message .body = "Это text body"
374
+ self .message .send ()
375
+
376
+ raw_mime = self .get_send_params ()["Content" ]["Raw" ]["Data" ]
377
+ self .assertTrue (raw_mime .isascii ()) # 7-bit clean
378
+
379
+ sent_message = self .get_sent_message ()
380
+ part_encodings = [
381
+ (part .get_content_type (), part ["Content-Transfer-Encoding" ])
382
+ for part in sent_message .walk ()
383
+ ]
384
+ self .assertEqual (part_encodings , [("text/plain" , "quoted-printable" )])
385
+
358
386
def test_api_failure (self ):
359
387
error_response = {
360
388
"Error" : {
0 commit comments