From 432f2854d5f486f89bc24ee06ee700695a7c0037 Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Sun, 19 Jan 2020 16:19:55 +0530 Subject: [PATCH] Add email backend --- backends/mail.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 backends/mail.py 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"])