From 724ab035630ee9077fb940c34c14dfede9e9e938 Mon Sep 17 00:00:00 2001 From: Ronald Schaten Date: Tue, 19 Mar 2013 20:19:43 +0100 Subject: [PATCH] implemented sending mail --- atomstrom.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/atomstrom.py b/atomstrom.py index 63ddb45..cad04e6 100755 --- a/atomstrom.py +++ b/atomstrom.py @@ -13,6 +13,7 @@ import hn import html2text import ConfigParser import smtplib +from email.mime.text import MIMEText from optparse import OptionParser Base = declarative_base() @@ -133,6 +134,14 @@ class Entry(Base): def send_mail(sender, receiver, subject, body): print 'sending to %s: %s' % (receiver.decode('latin-1'), subject.decode('latin-1')) + mail = MIMEText(body) + mail['From'] = sender + mail['To'] = receiver + mail['Subject'] = subject + mailserver = smtplib.SMTP('localhost') + mailserver.sendmail(sender, [receiver], mail.as_string()) + mailserver.quit() + def get_entry_text(entry): if entry.readability: