fix: relay raw SMTP bytes without decoding
Build and publish container / build (pull_request) Successful in 9m6s

send_message decoded the message body with utf-8/errors="replace",
corrupting 8-bit content before forwarding. Pass the raw bytes straight
to smtp.sendmail so the message is relayed unchanged.

Fixes #4

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-17 17:19:13 +01:00
parent a29889b731
commit df19c60b17
2 changed files with 6 additions and 4 deletions
+1 -2
View File
@@ -416,7 +416,6 @@ class SMTPProxyHandler:
def send_message(self, sender, recipients, data):
"""Forward a complete SMTP message to the backend SMTP server."""
message = data.decode("utf-8", errors="replace")
if Settings.BACKEND_SMTP_USE_SSL:
smtp = smtplib.SMTP_SSL(Settings.BACKEND_SMTP_HOST, Settings.BACKEND_SMTP_PORT, timeout=30)
else:
@@ -426,7 +425,7 @@ class SMTPProxyHandler:
try:
if Settings.BACKEND_SMTP_USER and Settings.BACKEND_SMTP_PASS:
smtp.login(Settings.BACKEND_SMTP_USER, Settings.BACKEND_SMTP_PASS)
smtp.sendmail(sender, recipients, message)
smtp.sendmail(sender, recipients, data)
finally:
smtp.quit()