healthcare email: add List-Unsubscribe/List-Id/Date/Precedence bulk headers to improve inbox placement on the cold hc IPs

This commit is contained in:
justin 2026-06-06 03:31:22 -05:00
parent 3859557506
commit 5129ebec5c

View file

@ -224,7 +224,7 @@ def cmd_render():
def cmd_send_test(to_addr: str, host: str, port: int):
ctx = None
from email.utils import formatdate
n = 0
for key in SEGMENTS:
subj, html = render(key, test=True)
@ -233,7 +233,16 @@ def cmd_send_test(to_addr: str, host: str, port: int):
msg["From"] = formataddr((FROM_NAME, FROM_EMAIL))
msg["To"] = to_addr
msg["Reply-To"] = REPLY_TO
msg["Date"] = formatdate(localtime=True)
msg["Message-ID"] = make_msgid(domain="performancewest.net")
# Bulk-mail deliverability headers (Gmail/GMX strongly reward these).
msg["List-Unsubscribe"] = (
f"<mailto:unsubscribe@performancewest.net?subject=unsubscribe>, "
f"<{SITE}/unsubscribe?e={to_addr}>")
msg["List-Unsubscribe-Post"] = "List-Unsubscribe=One-Click"
msg["List-Id"] = "Performance West Healthcare Compliance <hc.performancewest.net>"
msg["Precedence"] = "bulk"
msg["X-Entity-Ref-ID"] = make_msgid(domain="performancewest.net")
msg.attach(MIMEText("Please view this email in HTML.", "plain"))
msg.attach(MIMEText(html, "html"))
with smtplib.SMTP(host, port, timeout=15) as s: