-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoreviews.py
80 lines (67 loc) · 2.16 KB
/
noreviews.py
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
73
74
75
76
77
78
79
80
###
### sendinvites.py
###
from collections import namedtuple
import time
import re
import csv
import smtplib
SMTP_SERVER = 'email-smtp.us-east-1.amazonaws.com'
SMTP_USERNAME = # need to assign this
SMTP_PASSWORD = # need to assign this
CHAIRS_ADDR = # '[email protected]'
def read_pc(fname):
pclist = []
with open(fname, encoding='ISO-8859-1') as csvfile:
pcreader = csv.reader(csvfile, delimiter=',', quotechar='"')
headers = next(pcreader)
for row in pcreader:
pclist.append({key: value for key, value in zip(headers, row)})
return pclist
def send_nag(name, email, fromaddr):
toaddr = email
replytoaddr = CHAIRS_ADDR
cc = [CHAIRS_ADDR]
message_subject = "CCS Reviews Due Friday!"
with open ("nag.txt", "r") as myfile:
msg = ''.join([line for line in myfile.readlines()])
assert msg.find('$NAME') > 0
msg = msg.replace('$NAME', name, 1)
assert msg.find('$NAME') == -1
body = "From: %s\r\n" % fromaddr \
+ "To: %s\r\n" % toaddr \
+ "CC: %s\r\n" % ",".join(cc) \
+ "Reply-To: %s\r\n" % replytoaddr \
+ "Subject: %s\r\n" % message_subject \
+ "\r\n" \
+ msg
print(body)
toaddrs = [toaddr] + cc
smtp_server = SMTP_SERVER
smtp_username = SMTP_USERNAME
smtp_password = SMTP_PASSWORD
smtp_port = '587'
smtp_do_tls = True
server = smtplib.SMTP(
host = smtp_server,
port = smtp_port,
timeout = 10
)
server.set_debuglevel(10)
server.starttls()
server.ehlo()
server.login(smtp_username, smtp_password)
server.sendmail(fromaddr, toaddrs, body)
print (server.quit())
if __name__=="__main__":
pc = read_pc("noreviews.csv")
fromaddrs = {'Dave': 'David Evans <[email protected]>',
'Tal': 'Tal G. Malkin <[email protected]>',
'Dongyan': 'Dongyan Xu <[email protected]>' }
print ("Read PC list: " + str(len(pc)))
for p in pc:
print(p["Name"] + " - " + p["Email"])
assert '@' in p["Email"]
for p in pc:
send_nag(p["Name"], p["Email"], fromaddrs['Dave'])
time.sleep(10)