mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-09-04 23:17:34 +08:00
fix: smtp_proxy_server support decode from mail charset (#223)
This commit is contained in:
@@ -51,6 +51,7 @@ class CustomSMTPHandler:
|
|||||||
if msg.is_multipart():
|
if msg.is_multipart():
|
||||||
for part in msg.walk():
|
for part in msg.walk():
|
||||||
content_type = part.get_content_type()
|
content_type = part.get_content_type()
|
||||||
|
charset = part.get_content_charset()
|
||||||
payload = part.get_payload(decode=True)
|
payload = part.get_payload(decode=True)
|
||||||
if content_type not in ["text/plain", "text/html"]:
|
if content_type not in ["text/plain", "text/html"]:
|
||||||
_logger.warning(f"Skipping {content_type}")
|
_logger.warning(f"Skipping {content_type}")
|
||||||
@@ -59,7 +60,7 @@ class CustomSMTPHandler:
|
|||||||
continue
|
continue
|
||||||
content_list.append({
|
content_list.append({
|
||||||
"type": content_type,
|
"type": content_type,
|
||||||
"value": payload.decode()
|
"value": payload.decode(charset)
|
||||||
})
|
})
|
||||||
elif msg.get_content_type() in ["text/plain", "text/html"] and msg.get_payload(decode=True):
|
elif msg.get_content_type() in ["text/plain", "text/html"] and msg.get_payload(decode=True):
|
||||||
content_list.append({
|
content_list.append({
|
||||||
@@ -97,7 +98,7 @@ class CustomSMTPHandler:
|
|||||||
"is_html": body["type"] == "text/html",
|
"is_html": body["type"] == "text/html",
|
||||||
"content": body["value"],
|
"content": body["value"],
|
||||||
}
|
}
|
||||||
_logger.info(f"Send mail {send_body}")
|
_logger.info(f"Send mail {dict(send_body, token='***')}")
|
||||||
try:
|
try:
|
||||||
res = requests.post(
|
res = requests.post(
|
||||||
f"{settings.proxy_url}/external/api/send_mail",
|
f"{settings.proxy_url}/external/api/send_mail",
|
||||||
|
|||||||
Reference in New Issue
Block a user