1
0
Fork 0
mirror of https://github.com/Findus23/shuffle.git synced 2024-09-19 14:43:45 +02:00
shuffle/mail.py

18 lines
470 B
Python
Raw Permalink Normal View History

2020-05-08 14:20:41 +02:00
import smtplib
from email.mime.text import MIMEText
2020-05-08 14:26:10 +02:00
from config import sender, debug
2020-05-08 14:20:41 +02:00
s = smtplib.SMTP('localhost')
def notify(name: str, email: str, chosen_person: str) -> None:
to = f"{name} <{email}>"
msg = MIMEText(f"Hello {name},\n\nThe chosen person is {chosen_person}.")
msg['Subject'] = f"Result of shuffle for {name}"
msg['From'] = sender
msg['To'] = to
2020-05-08 14:26:10 +02:00
if debug: print(msg.as_string())
2020-05-08 14:20:41 +02:00
s.sendmail(sender, [to], msg.as_string())