From c00e57756336358e9800fc8fc89392253dbf4ed8 Mon Sep 17 00:00:00 2001 From: Markus Krogh Date: Tue, 8 Mar 2016 18:51:12 +0000 Subject: Initial commmit, still needs wireing for email --- maconomy/mailer.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 maconomy/mailer.py (limited to 'maconomy/mailer.py') diff --git a/maconomy/mailer.py b/maconomy/mailer.py new file mode 100644 index 0000000..ab443c0 --- /dev/null +++ b/maconomy/mailer.py @@ -0,0 +1,20 @@ +import smtplib +from email.mime.text import MIMEText + +class Mailer: + def __init__(self, config): + self.me = config.get("mail", "from") + server_addr = config.get("mail", "server") + self.server = smtplib.SMTP(server_addr) + + def send(to, subject, body): + msg = MIMEText(body,'plain') + msg['To']=to + msg['From']=self.me + msg['Subject'] = subject + self.server.sendmail(self.me, to, msg.as_string()) + + def close(self): + self.server.quit() + + -- cgit v1.1