source: TI03-DataExtractor/branches/old_stuff/dx-0.1.0/mailUser.py @ 793

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI03-DataExtractor/branches/old_stuff/dx-0.1.0/mailUser.py@793
Revision 793, 873 bytes checked in by astephen, 13 years ago (diff)

Put all the old code in the old_stuff branch.

Line 
1"""
2mailUser.py
3===========
4
5Holds the MailUser class used to contact the user via e-mail to
6inform them of an event.
7
8"""
9
10# Import python standard library modules
11import smtplib
12
13# Import package modules
14from config import LOCAL_MAIL_HOST, admin_mail_address, package_name
15
16# Set global variables
17
18
19class MailUser:
20
21    def __init__(self, userEmail, subject):
22        self.email=userEmail
23        self.subject=subject
24        self.mailserver=smtplib.SMTP(LOCAL_MAIL_HOST)
25        self.mailserver.set_debuglevel(1)
26       
27    def sendMail(self, message):
28        fromaddr=admin_mail_address
29        mail_content="""To: %s
30From: %s
31Subject: %s
32This message has been automatically generated by the %s\n
33%s""" % (self.email, fromaddr, self.subject, package_name, message)
34
35        self.mailserver.sendmail(fromaddr, self.email, mail_content)
36        self.mailserver.quit()
Note: See TracBrowser for help on using the repository browser.