@@ -61,6 +61,7 @@ def _translate_keys(self, **kwargs):
61
61
model ['recipients' ]['list_id' ] = recipient_list
62
62
else :
63
63
recipients = kwargs .get ('recipients' , [])
64
+ recipients = self ._extract_recipients (recipients )
64
65
cc = kwargs .get ('cc' )
65
66
bcc = kwargs .get ('bcc' )
66
67
@@ -72,7 +73,7 @@ def _translate_keys(self, **kwargs):
72
73
bcc_copies = self ._format_copies (recipients , bcc )
73
74
recipients = recipients + bcc_copies
74
75
75
- model ['recipients' ] = self . _extract_recipients ( recipients )
76
+ model ['recipients' ] = recipients
76
77
77
78
attachments = kwargs .get ('attachments' , [])
78
79
model ['content' ]['attachments' ] = self ._extract_attachments (
@@ -90,9 +91,19 @@ def _format_copies(self, recipients, copies):
90
91
if len (recipients ) > 0 :
91
92
formatted_copies = self ._extract_recipients (copies )
92
93
for recipient in formatted_copies :
93
- recipient ['address' ].update ({'header_to' : recipients [0 ]})
94
+ recipient ['address' ].update ({
95
+ 'header_to' : self ._format_header_to (recipients [0 ])
96
+ })
94
97
return formatted_copies
95
98
99
+ def _format_header_to (self , recipient ):
100
+ if 'name' in recipient ['address' ]:
101
+ return '"{name}" <{email}>' .format (
102
+ name = recipient ['address' ]['name' ],
103
+ email = recipient ['address' ]['email' ]
104
+ )
105
+ return recipient ['address' ]['email' ]
106
+
96
107
def _extract_attachments (self , attachments ):
97
108
formatted_attachments = []
98
109
for attachment in attachments :
0 commit comments