Use email.utils.formatdate() for dates in headers

This commit is contained in:
Kumi 2022-03-30 16:14:28 +02:00
parent 4a45a9360b
commit 226fd75a55

View file

@ -1,7 +1,7 @@
import uuid
import json
from datetime import datetime
from email.utils import formatdate
from pathlib import Path
@ -21,9 +21,9 @@ class SmtpdHandler:
try:
with open(Path(self.config.maildir) / f"{eid}.eml", "wb") as mailfile:
mailfile.write(
f"From {envelope.mail_from} {datetime.now().isoformat()}\n".encode())
f"From {envelope.mail_from} {formatdate()}\n".encode())
mailfile.write(
f"Received: from {session.host_name} ({session.peer[0]}) by {server.hostname} (Kumi Systems FileMailer) id {eid}; {datetime.now().isoformat()}\n".encode())
f"Received: from {session.host_name} ({session.peer[0]}) by {server.hostname} (Kumi Systems FileMailer) id {eid}; {formatdate()}\n".encode())
mailfile.write(envelope.original_content)
with open(Path(self.config.maildir) / f"{eid}.json", "w") as jsonfile:
data = {