48 try: |
49 try: |
49 self.bSSL=cp.getboolean(self.section, 'SSL') |
50 self.bSSL=cp.getboolean(self.section, 'SSL') |
50 except ValueError: |
51 except ValueError: |
51 self.bSSL=False |
52 self.bSSL=False |
52 |
53 |
53 |
|
54 def prepareSMTP(self): |
54 def prepareSMTP(self): |
55 if self.bSSL: |
55 if self.bSSL: |
56 self.smtp = smtplib.SMTP_SSL(self.host,self.port) |
56 self.smtp = smtplib.SMTP_SSL(self.host,self.port) |
57 else: |
57 else: |
58 self.smtp = smtplib.SMTP(self.host,self.port) |
58 self.smtp = smtplib.SMTP(self.host,self.port) |
68 def sendMail(self,mail,recipients): |
68 def sendMail(self,mail,recipients): |
69 if not self.bStart: |
69 if not self.bStart: |
70 self.prepareSMTP() |
70 self.prepareSMTP() |
71 |
71 |
72 mail.content['From']=self.send_from |
72 mail.content['From']=self.send_from |
|
73 |
73 while len(recipients) > 0: |
74 while len(recipients) > 0: |
74 tmp_recipients=recipients[:self.max_recipients] |
75 tmp_recipients=recipients[:self.max_recipients] |
75 print tmp_recipients |
|
76 self.smtp.sendmail(self.send_from, tmp_recipients, mail.as_string()) |
76 self.smtp.sendmail(self.send_from, tmp_recipients, mail.as_string()) |
77 self.updateStatus( arranged=tmp_recipients) |
77 self.updateStatus( arranged=tmp_recipients) |
78 recipients = recipients[self.max_recipients:] |
78 recipients = recipients[self.max_recipients:] |
79 |
79 |
80 self.smtp.shutdownSMTP() |
80 self.shutdownSMTP() |
81 |
81 |
82 |
82 |
83 def updateStatus(self, arranged=None, failed=None): |
83 def updateStatus(self, arranged=None, failed=None): |
84 """is a function that is called, if a new SMS/FAX was send |
84 """is a function that is called, if a new SMS/FAX was send |
85 -arranged is non None, if SMS/FAX was sended successfully |
85 -arranged is non None, if SMS/FAX was sended successfully |