Python Imaplib: Get new gmail mails without reconnect
问题 I'm writing a python script that regularly checks for new email matching a certain search. However it never shows new emails without reconnecting. mail = imaplib.IMAP4_SSL('imap.gmail.com') mail.login(user,passwd) mail.select("inbox") while True: result, idData = mail.uid('search', query, "ALL") processIDs(idData) time.sleep(60) The search finds all emails that match my query at login time, but it never finds emails that arrive while it's running. As soon as I stop the script and restart it,