Fix: Date-Header in ausgehenden Mails (formatdate UTC, Container hat keine lokale TZ)
This commit is contained in:
parent
865407d428
commit
af039efe82
1 changed files with 3 additions and 0 deletions
|
|
@ -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:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue