@@ -61,6 +61,7 @@ def _translate_keys(self, **kwargs):
6161 model ['recipients' ]['list_id' ] = recipient_list
6262 else :
6363 recipients = kwargs .get ('recipients' , [])
64+ recipients = self ._extract_recipients (recipients )
6465 cc = kwargs .get ('cc' )
6566 bcc = kwargs .get ('bcc' )
6667
@@ -72,7 +73,7 @@ def _translate_keys(self, **kwargs):
7273 bcc_copies = self ._format_copies (recipients , bcc )
7374 recipients = recipients + bcc_copies
7475
75- model ['recipients' ] = self . _extract_recipients ( recipients )
76+ model ['recipients' ] = recipients
7677
7778 attachments = kwargs .get ('attachments' , [])
7879 model ['content' ]['attachments' ] = self ._extract_attachments (
@@ -90,9 +91,19 @@ def _format_copies(self, recipients, copies):
9091 if len (recipients ) > 0 :
9192 formatted_copies = self ._extract_recipients (copies )
9293 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+ })
9497 return formatted_copies
9598
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+
96107 def _extract_attachments (self , attachments ):
97108 formatted_attachments = []
98109 for attachment in attachments :
0 commit comments