-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemail_notice.py
executable file
·42 lines (30 loc) · 1005 Bytes
/
email_notice.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
#!/usr/bin/env python
import sys
import json
import os.path
import smtplib
if __name__ == "__main__":
#js_file ='/home/training/erica/japan/jpHotel/hotel.json'
#try:
# os.path.isfile(js_file)
#except IOError:
# print 'Oh no..File is missing'
# sys.exit(0)
#json_data=open(js_file)
#data = json.load(json_data)
#max_month = data[-1]
#result = ', '.join(['{}_{}'.format(k,v) for k,v in max_month.iteritems()])
sender='[email protected]'
receivers = ['[email protected]']
#message = 'The contents of %s' % (result)
message = '''From: From Person <[email protected]>
To: To Person <[email protected]>
Subject: Crontab note for backup on elephant03
This is a note from crontab. %s
''' % ("Erica L Li")
try:
smtpObj = smtplib.SMTP('localhost')
smtpObj.sendmail(sender, receivers, message)
print "Successfully sent email"
except SMTPException:
print "Error: unable to send email"