support non TSL SMTP servers

pull/191/head
CD Nguyen 2018-03-30 11:35:37 +02:00
parent 053cc6dd27
commit e9e3f17363
2 changed files with 29 additions and 1 deletions

View File

@ -73,3 +73,29 @@ def sendEmailNotification(recipient, term):
except Exception as e:
print str(e)
# raise e
elif (
sender is not None and
sender_host is not None and
sender_port is not None
):
try:
server = smtplib.SMTP(sender_host, sender_port)
mime_msg = MIMEMultipart()
mime_msg['From'] = sender
mime_msg['To'] = recipient
mime_msg['Subject'] = "AIL Term Alert"
body = "New occurrence for term: " + term
mime_msg.attach(MIMEText(body, 'plain'))
server.sendmail(sender, recipient, mime_msg.as_string())
server.quit()
except Exception as e:
print str(e)
# raise e

View File

@ -23,7 +23,9 @@ sentiment_lexicon_file = sentiment/vader_lexicon.zip/vader_lexicon/vader_lexicon
sender = sender@example.com
sender_host = smtp.example.com
sender_port = 1337
sender_pw = securepassword
# optional for using with authenticated SMTP over SSL
# sender_pw = securepassword
##### Flask #####
[Flask]