use msg.as_bytes() instead of msg.as_string().encode()
This commit is contained in:
parent
2041b0aabd
commit
55190ff358
|
@ -227,7 +227,7 @@ def send_email(
|
|||
email_domain = SUPPORT_EMAIL[SUPPORT_EMAIL.find("@") + 1 :]
|
||||
add_dkim_signature(msg, email_domain)
|
||||
|
||||
msg_raw = msg.as_string().encode()
|
||||
msg_raw = msg.as_bytes()
|
||||
smtp.sendmail(SUPPORT_EMAIL, to_email, msg_raw)
|
||||
|
||||
|
||||
|
@ -253,7 +253,7 @@ def add_dkim_signature(msg: Message, email_domain: str):
|
|||
# Specify headers in "byte" form
|
||||
# Generate message signature
|
||||
sig = dkim.sign(
|
||||
msg.as_string().encode(),
|
||||
msg.as_bytes(),
|
||||
DKIM_SELECTOR,
|
||||
email_domain.encode(),
|
||||
DKIM_PRIVATE_KEY.encode(),
|
||||
|
|
|
@ -504,11 +504,10 @@ def handle_forward(envelope, smtp: SMTP, msg: Message, rcpt_to: str) -> (bool, s
|
|||
|
||||
# smtp.send_message has UnicodeEncodeErroremail issue
|
||||
# encode message raw directly instead
|
||||
msg_raw = msg.as_string().encode()
|
||||
smtp.sendmail(
|
||||
contact.reply_email,
|
||||
mailbox_email,
|
||||
msg_raw,
|
||||
msg.as_bytes(),
|
||||
envelope.mail_options,
|
||||
envelope.rcpt_options,
|
||||
)
|
||||
|
@ -645,11 +644,10 @@ def handle_reply(envelope, smtp: SMTP, msg: Message, rcpt_to: str) -> (bool, str
|
|||
if custom_domain.dkim_verified:
|
||||
add_dkim_signature(msg, alias_domain)
|
||||
|
||||
msg_raw = msg.as_string().encode()
|
||||
smtp.sendmail(
|
||||
alias.email,
|
||||
contact.website_email,
|
||||
msg_raw,
|
||||
msg.as_bytes(),
|
||||
envelope.mail_options,
|
||||
envelope.rcpt_options,
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue