def login(self, username, pwd): try: BaseIMAP.login(self, username, pwd) # superclass login except BaseIMAP.error, e: if str(e) == "permission denied": print "There was an error logging in to the IMAP server." print "The userid and/or password may be incorrect." sys.exit() else: raise
def imapConnection(self): # Connexion au serveur IMAP try: imap = IMAP(self.imap_host) print( '\nConnection to IMAP server intitialization of IMAP instance\n' ) imap.login(self.imap_user, self.imap_pass) print('Log in !\n') imap.select('INBOX') self.deleteMails(imap) return imap except gaierror: print('Can\'t reach IMAP server\n') except IMAP.error as e: print('Log in failed.\n') print(str(e) + '\n')
def loop(): server = IMAP(HOST, 993) server.login(USER, PWD) server.select(FOLDER, readonly=True) status, folder_status = server.status(FOLDER, "(UNSEEN)") print(status) print(folder_status) match = re.search("UNSEEN (\d+)", folder_status[0].decode(encoding="UTF-8")) print(match.group(0)) print(match.group(1)) if (match.group(1) == 1): print("You have mail!") GPIO.output(GREEN_LED, True) GPIO.output(RED_LED, False) else: print("No unread mail") GPIO.output(GREEN_LED, False) GPIO.output(RED_LED, True)
def loop(): server = IMAP(HOSTNAME, 993) server.login(USERNAME, PASSWORD) server.select(MAILBOX, readonly=True) result, folder_status = server.status(MAILBOX, '(UNSEEN)') #print(folder_status) m = re.search('UNSEEN (\d+)', folder_status[0].decode(encoding='UTF-8')) #print(m.group(0)) #print(m.group(1)) print("You have " + m.group(1) + " unread emails.") if (int(m.group(1)) > 0): GPIO.output(outpin1, True) GPIO.output(outpin2, False) else: GPIO.output(outpin1, False) GPIO.output(outpin2, True) time.sleep(3)
def login(imap: imaplib.IMAP4_SSL, username: str, password: str): imap.login(username, password)
def login(mail: str, password: str, con: imaplib.IMAP4_SSL) -> Optional[bool]: try: status, data = con.login(user=mail, password=password) return status == 'OK' except Exception as error: logging.error(error)