Advertisement
Guest User

Untitled

a guest
Apr 18th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import os
  3. import time
  4. import datetime
  5. import glob
  6. import smtplib
  7. from email.mime.text import MIMEText
  8. import string
  9.  
  10. username = 'danielsreeftank'
  11. password = 'Reeftank1'
  12. From = "danielsreeftank@gmail.com"
  13. To = "2252888042@mms.att.net"
  14. Subject_wet = "Warning"
  15.  
  16. def email(condition):
  17. #print "Attempting to send email"
  18. if condition == 'warning':
  19. Body = string.join((
  20. "From: %s" % From,
  21. "To: %s" % To,
  22. "Subject: %s" % Subject_wet,
  23. "",
  24. last,
  25. ), "\r\n")
  26.  
  27. # The actual mail send
  28. server = smtplib.SMTP('smtp.gmail.com:587')
  29. server.starttls()
  30. #print "Logging in..."
  31. server.login(username,password)
  32. #print "Logged in as "+username+"."
  33. server.sendmail(From, [To], Body)
  34. server.quit()
  35. #print "Email sent."
  36.  
  37. logsize = os.path.getsize('/home/pi/log')
  38. if logsize < 900 and logsize > 1:
  39. with open('/home/pi/log') as f:
  40. last = None
  41. for last in (line for line in f if line.rstrip('\n')):
  42. pass
  43. email('warning')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement