Subversion Repositories SmartDukaan

Rev

Rev 3987 | Rev 4796 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3987 Rev 4795
Line 1... Line 1...
1
from shop2020.thriftpy.utils.ttypes import Mail
1
from email.mime.text import MIMEText
2
from shop2020.clients.HelperClient import HelperClient
2
from shop2020.clients.HelperClient import HelperClient
-
 
3
from shop2020.thriftpy.utils.ttypes import Mail
-
 
4
import sched
-
 
5
import time
-
 
6
import smtplib
-
 
7
import sys
3
 
8
 
4
from email.mime.text import MIMEText
-
 
5
import sched, time, smtplib
-
 
6
 
9
 
7
class EmailSender():
10
class EmailSender():
8
    def __init__(self):
11
    def __init__(self):
9
        print 'EmailSender initiated at', time.time()
12
        print 'EmailSender initiated at', time.time()
10
        self.email_schedular = sched.scheduler(time.time, time.sleep)
13
        self.email_schedular = sched.scheduler(time.time, time.sleep)
Line 23... Line 26...
23
            self.mailServer.ehlo()
26
            self.mailServer.ehlo()
24
            self.mailServer.login(self.sender, self.password)
27
            self.mailServer.login(self.sender, self.password)
25
            print "Authentication successful", time.time()
28
            print "Authentication successful", time.time()
26
            
29
            
27
        except smtplib.SMTPConnectError as e:
30
        except smtplib.SMTPConnectError as e:
28
            print 'Specified host did not respond correctly', e
31
            print 'Specified host did not respond correctly', e        
29
        
-
 
30
        except smtplib.SMTPHeloError as e:
32
        except smtplib.SMTPHeloError as e:
31
            print 'The server did not reply properly to the HELO greeting.', e
33
            print 'The server did not reply properly to the HELO greeting.', e
32
        
-
 
33
        except smtplib.SMTPAuthenticationError as e:
34
        except smtplib.SMTPAuthenticationError as e:
34
            print 'The server did not accept the username/password combination.', e
35
            print 'The server did not accept the username/password combination.', e
35
        
-
 
36
        except smtplib.SMTPException as e:
36
        except smtplib.SMTPException as e:
37
            print e
37
            print e
-
 
38
        except Exception as e:
-
 
39
            print sys.exc_info()[0]
-
 
40
            print e
38
            
41
            
39
    def sendMail(self, mail):
42
    def sendMail(self, mail):
40
        if mail.sender:
43
        if mail.sender:
41
            mail.data = "This mail is sent by " + mail.sender + "\n" + mail.data
44
            mail.data = "This mail is sent by " + mail.sender + "\n" + mail.data
42
        
45