fix: e-mails carry a Date header, which spam filters expect
Some checks failed
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 3m21s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Failing after 54s
Some checks failed
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 3m21s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Failing after 54s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -21,7 +21,7 @@ import os
|
||||
import smtplib
|
||||
import ssl
|
||||
from email.message import EmailMessage
|
||||
from email.utils import formataddr, make_msgid, parseaddr
|
||||
from email.utils import formataddr, formatdate, make_msgid, parseaddr
|
||||
|
||||
ADAPTER = os.environ.get('MAIL_ADAPTER', 'off')
|
||||
RESET_MINUTES = 60
|
||||
@@ -102,6 +102,8 @@ def message(to, subject, body, html=None):
|
||||
msg['From'] = formataddr((name or 'DTF Dropstar', address))
|
||||
msg['To'] = to
|
||||
msg['Subject'] = subject
|
||||
# Neither EmailMessage nor smtplib adds it, and filters (Outlook's among them) count it missing.
|
||||
msg['Date'] = formatdate(localtime=True)
|
||||
msg['Message-ID'] = make_msgid(domain=address.split('@')[-1] or None)
|
||||
reply = os.environ.get('MAIL_REPLY_TO', '')
|
||||
if reply:
|
||||
|
||||
@@ -5,6 +5,7 @@ The local stack keeps e-mail in the database (MAIL_ADAPTER=log); the SMTP
|
||||
path is checked against a small SMTP server this test runs itself.
|
||||
"""
|
||||
import email
|
||||
import email.utils
|
||||
import hashlib
|
||||
import os
|
||||
import re
|
||||
@@ -259,6 +260,7 @@ def smtp_delivery(tag):
|
||||
rcpt, first = sink.messages[0]
|
||||
assert to in rcpt[0] and first['Subject'] == 'Crie uma nova senha · DTF Dropstar'
|
||||
assert first['From'] == 'DTF Dropstar <nao-responda@dropstar.test>'
|
||||
assert first['Date'] and email.utils.parsedate_to_datetime(first['Date'])
|
||||
assert first.get_content().strip() == 'link secreto ção'
|
||||
with db.connect() as c:
|
||||
sent = {r['kind']: r for r in queued(c, to, 'reset') + queued(c, to, 'test') + queued(c, to, 'code')}
|
||||
|
||||
Reference in New Issue
Block a user