mirror of
https://github.com/simple-login/app.git
synced 2025-02-25 00:03:03 +08:00
handle UnicodeEncodeError in encode()
This commit is contained in:
parent
db04303172
commit
84b4c11086
1 changed files with 6 additions and 1 deletions
|
@ -710,7 +710,12 @@ def to_bytes(msg: Message):
|
|||
LOG.warning(
|
||||
"as_bytes fails with SMTPUTF8 policy, try converting to string"
|
||||
)
|
||||
return msg.as_string().encode()
|
||||
msg_string = msg.as_string()
|
||||
try:
|
||||
return msg_string.encode()
|
||||
except UnicodeEncodeError as e:
|
||||
LOG.w("can't encode msg, err:%s", e)
|
||||
return msg_string.encode(errors="replace")
|
||||
|
||||
|
||||
def should_add_dkim_signature(domain: str) -> bool:
|
||||
|
|
Loading…
Reference in a new issue