Subversion Repositories SmartDukaan

Rev

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

Rev 15010 Rev 16438
Line 23... Line 23...
23
        self.time_to_sleep = 10
23
        self.time_to_sleep = 10
24
        self.count = count
24
        self.count = count
25
        self.exceptionCount = {}
25
        self.exceptionCount = {}
26
        self.authenticate()
26
        self.authenticate()
27
 
27
 
28
    def authenticate(self):
28
    def authenticate(self, sender="euser", password="shop2020"):
29
        try:
29
        try:
30
            print "Attempting authentication at ", time.time()
30
            print "Attempting authentication at ", time.time()
31
            self.sendGridMailServer = smtplib.SMTP("smtp.sendgrid.net", 587)
31
            self.sendGridMailServer = smtplib.SMTP("smtp.sendgrid.net", 587)
32
            self.sendGridSender = "euser"
32
            self.sendGridSender = sender
33
            self.sendGridPassword = "shop2020"
33
            self.sendGridPassword = password
34
            self.sendGridMailServer.ehlo()
34
            self.sendGridMailServer.ehlo()
35
            self.sendGridMailServer.starttls()
35
            self.sendGridMailServer.starttls()
36
            self.sendGridMailServer.ehlo()
36
            self.sendGridMailServer.ehlo()
37
            self.sendGridMailServer.login(self.sendGridSender, self.sendGridPassword)
37
            self.sendGridMailServer.login(sender, password)
38
 
38
 
39
#            self.gmailServer = smtplib.SMTP("smtp.gmail.com", 587)
39
#            self.gmailServer = smtplib.SMTP("smtp.gmail.com", 587)
40
#            self.gmailSender = "help@shop2020.in"
40
#            self.gmailSender = "help@shop2020.in"
41
#            self.gmailPassword = "5h0p2o2o"
41
#            self.gmailPassword = "5h0p2o2o"
42
#            self.gmailServer.ehlo()
42
#            self.gmailServer.ehlo()
Line 96... Line 96...
96
                if document != bin(0):
96
                if document != bin(0):
97
                    msg.attach(self.get_attachment_part(document, mail.source))
97
                    msg.attach(self.get_attachment_part(document, mail.source))
98
            
98
            
99
        try:
99
        try:
100
            self.setMailServerAndPassword(mail)
100
            self.setMailServerAndPassword(mail)
-
 
101
            if 'profitmandi.com' in mail.emailFrom:
-
 
102
                self.authenticate("profitmandi","pma20aug")
101
            rs = self.mailServer.sendmail(self.password, mail.emailTo + mail.cc + mail.bcc + ['backup@saholic.com'], msg.as_string())
103
                rs = self.mailServer.sendmail(self.password, mail.emailTo + mail.cc + mail.bcc + ['backup@saholic.com'], msg.as_string())
-
 
104
            else:
-
 
105
                self.authenticate()
-
 
106
                rs = self.mailServer.sendmail(self.password, mail.emailTo + mail.cc + mail.bcc + ['backup@saholic.com'], msg.as_string())
102
        except smtplib.SMTPServerDisconnected as e:
107
        except smtplib.SMTPServerDisconnected as e:
103
            print 'Server Disconnected at', time.time()
108
            print 'Server Disconnected at', time.time()
104
            self.authenticate()
109
            self.authenticate()
105
            rs = self.mailServer.sendmail(self.password, mail.emailTo + mail.cc + mail.bcc + ['backup@saholic.com'], msg.as_string())
110
            rs = self.mailServer.sendmail(self.password, mail.emailTo + mail.cc + mail.bcc + ['backup@saholic.com'], msg.as_string())
106
        
111