Fix: Date-Header in ausgehenden Mails (formatdate UTC, Container hat keine lokale TZ)

This commit is contained in:
rene 2026-05-15 12:37:41 +02:00
parent 865407d428
commit af039efe82

View file

@ -16,6 +16,7 @@ from datetime import datetime
from email.mime.text import MIMEText from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart from email.mime.multipart import MIMEMultipart
from email.mime.application import MIMEApplication from email.mime.application import MIMEApplication
from email.utils import formatdate
import httpx import httpx
@ -92,6 +93,7 @@ def _build_mime_copy(to: str, subject: str, html: str, plain: str, attachments:
msg["Subject"] = subject msg["Subject"] = subject
msg["From"] = SMTP_FROM msg["From"] = SMTP_FROM
msg["To"] = to msg["To"] = to
msg["Date"] = formatdate(localtime=False)
return msg return msg
@ -154,6 +156,7 @@ def _send_smtp_sync(to: str, subject: str, html: str, plain: str, attachments: l
msg["Subject"] = subject msg["Subject"] = subject
msg["From"] = SMTP_FROM msg["From"] = SMTP_FROM
msg["To"] = to msg["To"] = to
msg["Date"] = formatdate(localtime=False)
msg_bytes = msg.as_bytes() msg_bytes = msg.as_bytes()
with smtplib.SMTP(SMTP_HOST, SMTP_PORT, timeout=10) as s: with smtplib.SMTP(SMTP_HOST, SMTP_PORT, timeout=10) as s: