source: PSPA/madxPSPA/testing/Notify.py @ 477

Last change on this file since 477 was 430, checked in by touze, 11 years ago

import madx-5.01.00

File size: 779 bytes
Line 
1#/usr/bin/python
2import smtplib
3from email.MIMEText import MIMEText
4
5def notify(recipient,subject,message):
6    # Set up a MIMEText object (it's a dictionary)
7
8    if recipient == 'jean-luc':
9        toAdrs = 'Jean-Luc.Nougaret@cern.ch'
10    elif recipient == 'admin':
11        toAdrs = 'mad-automation-admin@cern.ch'
12    else:
13        toAdrs = 'Jean-Luc.Nougaret@cern.ch'
14   
15    TEXT = message
16
17    msg = MIMEText(TEXT)
18   
19    msg['Subject'] = subject   
20    msg['To'] = toAdrs
21    # if above missing, message still gets delivered
22    # but with 'undisclosed recipients'
23
24    FROM = "Jean-Luc.Nougaret@cern.ch"
25    TO = [ toAdrs ] # must be a list
26
27    SERVER = 'localhost'
28   
29    server = smtplib.SMTP(SERVER)
30    server.sendmail(FROM,TO,msg.as_string())
31    server.quit()
Note: See TracBrowser for help on using the repository browser.