File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -27,13 +27,17 @@ def _sanitize_email(self, email: str) -> str:
27
27
return email .split ('<' )[1 ].split ('>' )[0 ]
28
28
return email
29
29
30
- def _format_email (self , email : str , name : Optional [str ] = None ) -> str :
30
+ def _format_email (self , email : str , name : Optional [str ] = None ) -> dict :
31
31
"""
32
32
Format email address with optional display name.
33
+ Returns a dictionary with email and name fields.
34
+ If no name is provided, uses the email address as the name.
33
35
"""
34
- if name :
35
- return formataddr ((name , self ._sanitize_email (email )))
36
- return self ._sanitize_email (email )
36
+ sanitized_email = self ._sanitize_email (email )
37
+ return {
38
+ 'email' : sanitized_email ,
39
+ 'name' : name if name else sanitized_email
40
+ }
37
41
38
42
def _send (self , email_message : Union [EmailMessage , EmailMultiAlternatives ]) -> bool :
39
43
"""
You can’t perform that action at this time.
0 commit comments