implemented sending mail

This commit is contained in:
Ronald Schaten 2013-03-19 20:19:43 +01:00
parent 193e47d2bb
commit 724ab03563

View File

@ -13,6 +13,7 @@ import hn
import html2text import html2text
import ConfigParser import ConfigParser
import smtplib import smtplib
from email.mime.text import MIMEText
from optparse import OptionParser from optparse import OptionParser
Base = declarative_base() Base = declarative_base()
@ -133,6 +134,14 @@ class Entry(Base):
def send_mail(sender, receiver, subject, body): def send_mail(sender, receiver, subject, body):
print 'sending to %s: %s' % (receiver.decode('latin-1'), subject.decode('latin-1')) 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): def get_entry_text(entry):
if entry.readability: if entry.readability: