diff options
Diffstat (limited to 'maconomy/mailer.py')
-rw-r--r-- | maconomy/mailer.py | 20 |
1 files changed, 20 insertions, 0 deletions
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() + + |