-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
60 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,6 +94,37 @@ def test_name_addr(self): | |
data["bcc"], ["Blind Copy <[email protected]>", "[email protected]"] | ||
) | ||
|
||
def test_quoted_display_names(self): | ||
# Resend's API has a bug that rejects a display-name that is quoted | ||
# (per RFC 5822 section 3.4). Attempting to omit the quotes works, unless | ||
# the display-name also contains a comma. Try to avoid the whole problem | ||
# by using RFC 2047 encoded words for addresses Resend will parse incorrectly. | ||
msg = mail.EmailMessage( | ||
"Subject", | ||
"Message", | ||
'"From, comma" <[email protected]>', | ||
[ | ||
'"To, comma" <[email protected]>', | ||
"non–ascii <[email protected]>", | ||
"=?utf-8?q?pre_encoded?= <[email protected]>", | ||
], | ||
reply_to=['"Reply, comma" <[email protected]>'], | ||
) | ||
msg.send() | ||
data = self.get_api_call_json() | ||
self.assertEqual(data["from"], "=?utf-8?q?From=2C_comma?= <[email protected]>") | ||
self.assertEqual( | ||
data["to"], | ||
[ | ||
"=?utf-8?q?To=2C_comma?= <[email protected]>", | ||
"=?utf-8?b?bm9u4oCTYXNjaWk=?= <[email protected]>", | ||
"=?utf-8?q?pre_encoded?= <[email protected]>", | ||
], | ||
) | ||
self.assertEqual( | ||
data["reply_to"], ["=?utf-8?q?Reply=2C_comma?= <[email protected]>"] | ||
) | ||
|
||
def test_email_message(self): | ||
email = mail.EmailMessage( | ||
"Subject", | ||
|