Logo Search packages:      
Sourcecode: fail2ban version File versions  Download package

def utils::mail::Mail::sendmail (   self,
  subject,
  message,
  aInfo 
)

Send an email using smtplib

Definition at line 58 of file mail.py.

00058                                                  :
            """ Send an email using smtplib
            """
            subj = replaceTag(subject, aInfo)
            msg = replaceTag(message, aInfo)
            
            mail = ("From: %s\r\nTo: %s\r\nDate: %s\r\nSubject: %s\r\n\r\n" %
                        (self.fromAddr, ", ".join(self.toAddr),
                        email.Utils.formatdate(localtime = self.localTimeFlag),
                        subj)) + msg
            
            try:
                  server = smtplib.SMTP(self.host, self.port)
                  #server.set_debuglevel(1)
                  server.sendmail(self.fromAddr, self.toAddr, mail)
                  logSys.debug("Email sent to " + `self.toAddr`)
                  server.quit()     
            except Exception, e:
                  logSys.error("Unable to send mail to " + self.host + ":" +
                                     `self.port` + " from " + self.fromAddr + " to " +
                                     `self.toAddr` + ": " + `e` + ": " + `e.args`)
            
            


Generated by  Doxygen 1.6.0   Back to index