diff options
author | Markus Krogh <markus@nordu.net> | 2016-03-08 18:51:12 +0000 |
---|---|---|
committer | Markus Krogh <markus@nordu.net> | 2016-03-08 18:51:12 +0000 |
commit | c00e57756336358e9800fc8fc89392253dbf4ed8 (patch) | |
tree | b005152d9bd390c3e2a8912247fff43dfbbbfde6 /maconomy/mailer.py | |
parent | 5c365f875986ffb38345e789a450639b1b833b24 (diff) |
Initial commmit, still needs wireing for email
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() + + |