forked from shakeh/bridge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
email_announce.py
61 lines (47 loc) · 1.52 KB
/
email_announce.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
#!/usr/bin/python
#
# Read a list of plain text abstracts from ADS and extract email lists.
# Usage python announce_email.py <email.address> <session_ID>
#
import sys
import smtplib
import base64
import re
import time
toaddr=sys.argv[1]
sessionID = sys.argv[2]
From = 'Andrea.Lommen@fandm.edu'
Return = 'Andrea.Lommen@fandm.edu'
marker = "======================================"
##############################
# Define the message body.
body = """Content-Type: text/plain; charset=\"us-ascii\"
Dear Bridge User,
Thank you for using the Bridge!
Please click on the links below to view the results of
your optimal statistic job submission to the Bridge.
http://thebridge.phys.wvu.edu/api/%s/optimal_stat/hd.png
http://thebridge.phys.wvu.edu/api/%s/optimal_stat/os_out.json
If you have questions about your analysis please reply to this email.
--%s
""" % (sessionID, sessionID, marker)
##############################
##############################
# Define the main headers.
header = """From: The Bridge c/o <andrea.lommen@fandm.edu>
To: %s
Subject: The Results of Your Recent Bridge Analysis, sessionID %s
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=\"%s\"
--%s
""" % (toaddr, sessionID, marker, marker)
message = header + body
print message
try:
smtpObj = smtplib.SMTP('smtp.wvu.edu')
smtpObj.sendmail(From, toaddr, message)
print "Email en route to %s ..." % email
smtpObj.quit()
except Exception:
print "Error: unable to send email"
time.sleep(3)