Subversion Repositories SmartDukaan

Rev

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

Rev 4971 Rev 5194
Line 47... Line 47...
47
        if mail.sender:
47
        if mail.sender:
48
            mail.data = "This mail is sent by " + mail.sender + "\n" + mail.data
48
            mail.data = "This mail is sent by " + mail.sender + "\n" + mail.data
49
        
49
        
50
        msg = MIMEText(mail.data, 'html')
50
        msg = MIMEText(mail.data, 'html')
51
        
51
        
52
        msg['To'] = mail.to
52
        msg['To'] = ';'.join(mail.to)
53
        
53
        
54
        if mail.sender:
54
        if mail.sender:
55
            msg['From'] = mail.sender
55
            msg['From'] = mail.sender
56
        else:
56
        else:
57
            msg['From'] = "help@saholic.com"
57
            msg['From'] = "help@saholic.com"
58
        msg['Subject'] = mail.subject
58
        msg['Subject'] = mail.subject
59
        
59
        
60
        try:
60
        try:
61
            rs = self.mailServer.sendmail(self.password, [mail.to], msg.as_string())
61
            rs = self.mailServer.sendmail(self.password, mail.to, msg.as_string())
62
            
62
            
63
        except smtplib.SMTPServerDisconnected as e:
63
        except smtplib.SMTPServerDisconnected as e:
64
            print 'Server Disconnected at', time.time()
64
            print 'Server Disconnected at', time.time()
65
            self.authenticate()
65
            self.authenticate()
66
            rs = self.mailServer.sendmail(self.password, [mail.to], msg.as_string())
66
            rs = self.mailServer.sendmail(self.password, mail.to, msg.as_string())
67
        
67
        
68
        print msg['To']
68
        print msg['To']
69
        # Should be mailServer.quit(), but that crashes...
69
        # Should be mailServer.quit(), but that crashes...
70
        return rs
70
        return rs
71
 
71
 
Line 75... Line 75...
75
        
75
        
76
        emails_to_be_dispatched = helper_client.getEmailsToBeSent()
76
        emails_to_be_dispatched = helper_client.getEmailsToBeSent()
77
        print len(emails_to_be_dispatched)
77
        print len(emails_to_be_dispatched)
78
        
78
        
79
        for email in emails_to_be_dispatched:
79
        for email in emails_to_be_dispatched:
-
 
80
            toList = []
-
 
81
            for to in email.emailTo.split(';') :
-
 
82
                toList.append(to.strip())
80
            mail = Mail(email.emailTo, email.subject, email.body, None, None, None)
83
            mail = Mail( toList, email.subject, email.body, None, None, None)
81
            
84
            
82
            try:
85
            try:
83
                send_result = self.sendMail(mail)
86
                send_result = self.sendMail(mail)
84
            except Exception as e:
87
            except Exception as e:
85
                print sys.exc_info()[0]
88
                print sys.exc_info()[0]