示例#1
0
 def run(self):
     try:
         self.gMailHost.secureSend(self.gMBodyFull, 
                                                    self.gMTo,
                                                    self.gMFrom, 
                                                    self.gMHeader,
                                                    self.gMCC, self.gMCCN, "html",charset="utf-8", **self.gOptions)
         log("Mail succesfully sent by thread " + str(self))                                                       
     except:
         type, val, tb = sys.exc_info()
         traceback.print_exc(file=sys.stdout)
         warn("Mail cannot be sent : \nException type: %s \nException value: %s \nException tb: %s" % (type, val, tb) )
示例#2
0
 def stateTransationNotify(self, stateChangeInfo):
     econtext = createExprContext(stateChangeInfo)
     
     mFROM = self._resolveMailFromAddress(econtext)
     mTO = self._resolveMailTOAddreses(econtext, stateChangeInfo)
     mCC = self._resolveMailCCAddreses(econtext, stateChangeInfo)
     mCCN = self._resolveMailCCNAddreses(econtext, stateChangeInfo)
     
     options = {}
     if self.message_id_expression:
         options["Message-Id"] = self.message_id_expression(econtext)
     if self.in_replay_to_expression:
         options["In-Reply-To"] = self.in_replay_to_expression(econtext)
     
     self.mail_header_dtml.__dict__.update(econtext.__dict__)
     mHeader = self.mail_header_dtml(client=stateChangeInfo.object)
     
     #TODO fix this patch
     mHeader = unicode(mHeader,"latin-1").encode("latin-1","replace")
     mHeadCss = self.mail_head_css_dtml(client=stateChangeInfo.object)
     mBody = self.mail_body_dtml(client=stateChangeInfo.object)
     if mHeadCss:
         mBodyFull = "<html> " + mHeadCss + mBody + " </html>"
     else:
         mBodyFull = "<html> " + mBody + " </html>"
     try:
         if mTO or mCC or mCCN:
             log("mTo: " + str(mTO))
             log("mFROM: " + str(mFROM))
             log("mCC: " + str(mCC))
             log("mCCN: " + str(mCCN))
             log("mHeader: " + str(mHeader))
             log("mBody: " + str(mBody))
             #~ self.MailHost.secureSend(  mBodyFull, mTO,
                                                         #~ mFROM, mHeader,
                                                         #~ mCC, mCCN, "html",charset="utf-8", **options)
             lThread = SenderThread(self.MailHost, mTO, mFROM, mCC, mCCN, mHeader, mBodyFull, options)
             lThread.start()
             log("Sender Thread started succesfully by " + str(lThread))
     except:
         type, val, tb = sys.exc_info()
         traceback.print_exc(file=sys.stdout)
         warn("Mail cannot be sent : \nException type: %s \nException value: %s \nException tb: %s" % (type, val, tb) )
         return self.plone_utils.addPortalMessage( u"the notification mail can't be sent! the server network services are not correctly configured or a firewall is blocking the nameserver lookups \n error: %s " % type)