Skip to content

Commit

Permalink
Merge pull request #243 from leffss/master
Browse files Browse the repository at this point in the history
  • Loading branch information
kootenpv committed Jul 1, 2022
2 parents 4cb9755 + 42d304d commit f0a50f6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion yagmail/headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import hashlib
from yagmail.compat import text_type
from yagmail.error import YagAddressError
from email.utils import formataddr


def resolve_addresses(user, useralias, to, cc, bcc):
Expand Down Expand Up @@ -59,7 +60,9 @@ def add_subject(msg, subject):
def add_recipients_headers(user, useralias, msg, addresses):
# Quoting the useralias so it should match display-name from https://tools.ietf.org/html/rfc5322 ,
# even if it's an email address.
msg["From"] = '"{0}" <{1}>'.format(useralias.replace("\\", "\\\\").replace('"', '\\"'), user)
# msg["From"] = '"{0}" <{1}>'.format(useralias.replace("\\", "\\\\").replace('"', '\\"'), user)
# formataddr can support From chinese useralias, just like: mail_user = {'notice@test.com': '中文测试'}
msg['From'] = formataddr(["{0}".format(useralias.replace("\\", "\\\\").replace('"', '\\"')), user])
if "To" in addresses:
msg["To"] = addresses["To"]
else:
Expand Down

0 comments on commit f0a50f6

Please sign in to comment.