Пример #1
0
 def sendMails(self):
     if self.mailsAvailable() > 0:
         if not basic.ping(self.mailServerAddress):
             return
         print 'LOGIN'
         self.mailClient.login()     
         while self.mailsAvailable() > 0:
             if not basic.ping(self.mailServerAddress):
                 self.mailClient.logout()
                 return
             print 'GET MAIL OBJECT'
             mail = self.queue.pop()
             print 'SEND MAIL'
             self.mailClient.sendMail(mail)
             
     return
Пример #2
0
 def run(self):
     psax = system.getRunningProcesses()
     if not 's87reconnect' in psax:
         online = False
         for server in self.onlineCheckIPs:
             if basic.ping(server):
                 online = True
                 break
         if online:
             if self.eventInAction:
                 self.offlineTime = self.getTime()-self.lastOnlineTime
                 subject = basic.HOSTNAME + ': connection error!'
                 message = 'Internet connection was down for '+ str(self.offlineTime) + ' sec.\nNew ip is ' + system.getExternIP()
                 self.sendMail(subject, message)                
             self.lastOnlineTime = self.getTime()
             self.eventInAction = False
             self.mailSended = False
         else:
             self.eventInAction = True
         if self.eventInAction:
             if self.lastOnlineTime <= self.getTime()-self.reactionTime:
                 if not self.mailSended:
                     subject = basic.HOSTNAME + ': connection error!'
                     message = 'Internet connection is down!'
                     self.sendMail(subject, message)
                     self.mailSended = True             
Пример #3
0
 def login(self, TLS=True):
     if not basic.ping(self.server):
         return False
     if self.pop3conn == None:
         self.pop3conn = poplib.POP3(self.server)
         self.pop3conn.getwelcome()
         self.pop3conn.user(self.username)
         self.pop3conn.pass_(basic.decrypt(basic.getHostKey(), self.password))
     if self.smtpconn == None:
         self.smtpconn = smtplib.SMTP(self.server)
         self.smtpconn.ehlo()
         self.smtpconn.starttls()
         self.smtpconn.ehlo()
         self.smtpconn.login(self.username, basic.decrypt(basic.getHostKey(), self.password))
     return True