From cf088f0bd31404e6f533f5ff4c628302d36df9b4a71e6edf3b9ddb57ae5ddc15 Mon Sep 17 00:00:00 2001 From: tlg Date: Thu, 9 Jul 2026 15:06:55 +0200 Subject: [PATCH] fix(projekt-matching): add Date and Message-ID headers to outgoing mail --- projekt-matching/projektmatch/mailer.py | 3 +++ projekt-matching/tests/test_mailer.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/projekt-matching/projektmatch/mailer.py b/projekt-matching/projektmatch/mailer.py index 1e964d4..66485e7 100644 --- a/projekt-matching/projektmatch/mailer.py +++ b/projekt-matching/projektmatch/mailer.py @@ -2,6 +2,7 @@ from __future__ import annotations import email +import email.utils import imaplib import smtplib import ssl @@ -71,6 +72,8 @@ class MailBox: def send_mail(user, password, to, subject, body): msg = EmailMessage() msg["From"], msg["To"], msg["Subject"] = user, to, subject + msg["Date"] = email.utils.formatdate(localtime=True) + msg["Message-ID"] = email.utils.make_msgid(domain="destengs.com") msg.set_content(body) with smtplib.SMTP(SMTP_HOST, SMTP_PORT, timeout=30) as server: server.starttls(context=ssl.create_default_context()) diff --git a/projekt-matching/tests/test_mailer.py b/projekt-matching/tests/test_mailer.py index 5189304..29385db 100644 --- a/projekt-matching/tests/test_mailer.py +++ b/projekt-matching/tests/test_mailer.py @@ -51,3 +51,5 @@ def test_send_mail_starttls(): server.login.assert_called_once_with("u@x", "pw") msg = server.send_message.call_args.args[0] assert msg["Subject"] == "Subj" and msg["To"] == "to@x" + assert msg["Date"] + assert msg["Message-ID"].endswith("@destengs.com>")