fix: add a message id and html body to reduce spam score
these changes should lower the spam score for systems that use e.g. spamassassin and increase the likelihood of the email being delivered.
This commit is contained in:
parent
fd0e30bca2
commit
b61d1dd8e2
1 changed files with 20 additions and 1 deletions
21
wichteln.py
21
wichteln.py
|
@ -11,7 +11,7 @@ buy presents for.
|
|||
from argparse import ArgumentParser
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
from email.utils import formatdate
|
||||
from email.utils import formatdate, make_msgid
|
||||
import json
|
||||
import random
|
||||
import smtplib
|
||||
|
@ -79,12 +79,31 @@ for r in participants:
|
|||
msg['From'] = config['sender']
|
||||
msg['To'] = r['mail']
|
||||
msg['Subject'] = 'Wichteln 🎄'
|
||||
msg['Message-ID'] = make_msgid(domain=config['sender']
|
||||
.split('@')[1]
|
||||
.strip('>'))
|
||||
msg['Date'] = formatdate(localtime=True)
|
||||
|
||||
body = 'Lieb'+r['gender']+' '+r['name']+'!\n\n'
|
||||
body += 'Du bist heuer Wichtel für '+r['partner']+'.\n'
|
||||
body += 'Das Geschenk sollte nicht mehr als 50€ kosten.\n\n'
|
||||
body += 'Frohe Weihnachten!\n— Dein Christkind 👼'
|
||||
|
||||
html = f"""
|
||||
<html>
|
||||
<head></head>
|
||||
<body>
|
||||
<p>Lieb{r['gender']} {r['name']}!<br><br>
|
||||
Du bist heuer Wichtel für {r['partner']}.<br>
|
||||
Das Geschenk sollte nicht mehr als 50€ kosten.<br><br>
|
||||
Frohe Weihnachten!<br>
|
||||
— Dein Christkind 👼
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
|
||||
msg.attach(MIMEText(body, 'plain', 'utf-8'))
|
||||
msg.attach(MIMEText(html, 'html', 'utf-8'))
|
||||
print("Sending email to", r['name'])
|
||||
server.sendmail(config['sender'], r['mail'], msg.as_string())
|
||||
|
|
Loading…
Reference in a new issue