From 27902ac31cf8041d70177ba7165ef886eac31318 Mon Sep 17 00:00:00 2001 From: Stefan Sterz Date: Sun, 9 Sep 2018 11:01:28 +0000 Subject: [PATCH] fix: minor inprovements --- wichteln.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/wichteln.py b/wichteln.py index ad8f1ae..98ad90e 100644 --- a/wichteln.py +++ b/wichteln.py @@ -1,6 +1,6 @@ ''' This script creates randoms pairs from a list of participants in a secret santa -game and sends them an email to notify them who the person is that they should +game and sends them an email to notify them who the person is that they should buy presents for. ''' @@ -8,6 +8,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 import json import random import smtplib @@ -76,11 +77,12 @@ for r in participants: msg['From'] = config['sender'] msg['To'] = r['mail'] msg['Subject'] = 'Wichteln 🎄' + msg['Date'] = formatdate(localtime=True) - body = 'Lieb'+r['gender']+' '+r['name']+'!' - body += '\n\nDu bist heuer Wichtel für '+r['partner'] - body += '. \n Das Geschenk sollte nicht mehr als 50€ kosten.' - body += '\nFrohe Weihnachten!\n\nDein Christkind 👼' + 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 👼' msg.attach(MIMEText(body, 'plain', 'utf-8')) server.sendmail(config['sender'], r['mail'], msg.as_string())