Merge pull request #11720 from saurabh6790/format-email-fix
fix: validate email id before passing to formataddr
This commit is contained in:
commit
3676f8dc6f
1 changed files with 7 additions and 2 deletions
|
|
@ -66,9 +66,14 @@ def get_email_address(user=None):
|
|||
def get_formatted_email(user, mail=None):
|
||||
"""get Email Address of user formatted as: `John Doe <johndoe@example.com>`"""
|
||||
fullname = get_fullname(user)
|
||||
|
||||
if not mail:
|
||||
mail = get_email_address(user)
|
||||
return cstr(make_header(decode_header(formataddr((fullname, mail)))))
|
||||
mail = get_email_address(user) or validate_email_address(user)
|
||||
|
||||
if not mail:
|
||||
return ''
|
||||
else:
|
||||
return cstr(make_header(decode_header(formataddr((fullname, mail)))))
|
||||
|
||||
def extract_email_id(email):
|
||||
"""fetch only the email part of the Email Address"""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue