diff --git a/backends/mail.py b/backends/mail.py new file mode 100644 index 0000000..b993986 --- /dev/null +++ b/backends/mail.py @@ -0,0 +1,19 @@ +import smtplib +from email.mime.text import MIMEText + + +def send(config, message): + if config["ssl"]: + smtp = smtplib.SMTP_SSL(config["url"], config["port"]) + smtp.starttls() + else: + smtp = smtplib.SMTP(config["url"], config["port"]) + if config["tls"]: + smtp.starttls() + + msg = MIMEText(message) + msg["Subject"] = "Access to The Long Night" + msg["From"] = config["from"] + msg["To"] = config["tos"] + smtp.login(config["login"], config["password"]) + smtp.send_message(msg, from_addr=config["from"], to_addrs=config["tos"])