-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathemailtest.py
More file actions
72 lines (52 loc) · 1.4 KB
/
emailtest.py
File metadata and controls
72 lines (52 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import os
import glob
import time
import urllib
import json
import netifaces
import gdata
import gdata.spreadsheet.service as gdss
import RPi.GPIO as GPIO
import smtplib
GREEN_LED = 24
RED_LED = 23
WARN_TEMP_HIGH = 85
WARN_TEMP_LOW = 40
EMAIL_LIST = [
# 'jbrodie@gmail.com',
'scott.brodie@mssm.edu',
# 'mgruen+lakehouse@gmail.com',
# 'lakehousepi@gmail.com'
]
USERNAME = 'lakehousepi@gmail.com'
PASSWORD = 'lakehousepi!'
def get_global_ip():
jss = urllib.URLopener().open('http://jsonip.com').read()
obj = json.loads(jss)
ip = obj['ip']
return ip
global_ip = get_global_ip()
local_ip = netifaces.ifaddresses("wlan0").get(netifaces.AF_INET)[0]['addr']
if True:
fromaddr = USERNAME
toaddrs = EMAIL_LIST
# if temp[1] > WARN_TEMP_HIGH:
# msg = 'Subject: The temperature is too darn high!\n\nIt is %d degrees in here!' % temp[1]
# else:
# msg = 'Subject: The temperature is too darn low!\n\nIt is %d degrees in here!' % temp[1]
username = USERNAME
password = PASSWORD
server = smtplib.SMTP('smtp.gmail.com:587')
server.starttls()
server.login(username, password)
server.sendmail(fromaddr, toaddrs, 'Foo')
server.quit()
# Prepare the dictionary to write
#dict = {}
#dict['date'] = time.strftime('%m/%d/%Y')
#dict['time'] = time.strftime('%H:%M:%S')
#dict['tempcentigrade'] = str(temp[0])
#$dict['tempfahrenheit'] = str(temp[1])
#dict['localip'] = local_ip
#dict['globalip'] = global_ip
print 'Foo'