email stuff

This commit is contained in:
hg 2015-07-23 15:03:48 +02:00
parent 332a731977
commit ccc578e963

View File

@ -5,6 +5,9 @@ from time import gmtime, strftime, sleep
import threading
import datetime
import pymongo
import smtplib
from email.mime.text import MIMEText
DEBUG = True
@ -114,6 +117,14 @@ class AlarmSender(threading.Thread):
while True:
try:
msg = self.queue.get()
emailMsg = MIMEText("Temperature in freezer to high: %s %s" % (msg['timestamp'], msg['temperature']))
emailMsg['Subject'] = 'Freezer Alarm'
emailMsg['From'] = 'freezer@hottis.de'
emailMsg['To'] = 'familie@hottis.de'
s = smtplib.SMTP('localhost')
s.sendmail('freezer@hottis.de', ['familie@hottis.de'], emailMsg.as_string())
s.quit()
Logger.debug("AlarmSender sends message for: %s" % msg)
except TypeError, e:
Logger.log("Exception %s in AlarmSender, run" % str(e))