-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmailer.py
44 lines (34 loc) · 1.77 KB
/
mailer.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
from bookkeeping import *
from subprocess import Popen, PIPE
def sendMail(message, subject, to):
echoed = Popen(['echo', message], stdout=PIPE)
Popen(['mail', '-s', subject, '-r', '[email protected]', to], stdin=echoed.stdout, stdout=PIPE)
def summary(total):
string = "Summary of all requests: \n"
for record in total:
string += str(record) + "\n"
return string
def sendKidMail(total, accepted):
days = str(accepted.days) #easy to concatenate as string
subject = "Requested " + accepted.days + " lateday(s)"
message = """Dear """ + accepted.user + """,
You requested """ + accepted.days + """ lateday(s) for """ + accepted.assignment + """ at """ + accepted.timestamp + """. Please notify us immediately at [email protected] if this is incorrect.
""" + summary(total) + """
Warning: This email is only to inform you how many latedays you requested on the Google form. Please ensure that you actually have the number of lateday(s) you requested left, and that the requested assignment was still open for latedays at the date/time indicated.
Thanks,
CSE 331 staff"""
sendMail(message, subject, accepted.user);
#print(message, subject, accepted.user);
def sendStaffMail(idToInfo, homework, failure_list):
message = "Late days requested for " + homework + ":\n\n"
for user, info in idToInfo.items():
message += str(info) + "\n"
if len(failure_list) > 0:
message += "\nCould not send email to these lines in the csv file:\n"
for fail in failure_list:
message += fail + "\n"
else:
message += "\nNo errors occurred while parsing the file\n"
subject = "Summary of late day requests for " + homework
sendMail(message, subject, "[email protected]")
#print "Called sendMail", message, subject