Ejemplo n.º 1
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
Ejemplo n.º 2
0
        self.queue.insert(0, Mail(sender, receiver, subject, content))

    def send(self):
        self.sendMails()

    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
                
if len(sys.argv) > 1:
    if sys.argv[1] == 'getmailpw':
        print basic.encrypt(basic.getHostKey(), 'ABCabc123456')
        sys.exit()

config = basic.s87config['s87notify'] 
mailServer= MailQueue(config['smtpConfig']['mailServer'], config['smtpConfig']['smtpUser'], basic.decrypt(basic.getHostKey(), config['smtpConfig']['password']))