Skip to content

Instantly share code, notes, and snippets.

@marcusscomputer
Created October 1, 2020 09:25
Show Gist options
  • Save marcusscomputer/c74e325fc9334ccaba18ef0e9398f347 to your computer and use it in GitHub Desktop.
Save marcusscomputer/c74e325fc9334ccaba18ef0e9398f347 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
"""
small script to check for unread count on imap inbox
"""
import imaplib
IMAPSERVER = 'YOUR.IMAP-SERVER.COM'
USER = 'EMAIL@NUTZERNAME'
PASSWORD = 'ACCOUNT-PASSWORT'
mail = imaplib.IMAP4_SSL(IMAPSERVER)
mail.login(USER, PASSWORD)
mail.select("INBOX", True) # connect to inbox.
return_code, mail_ids = mail.search(None, 'UnSeen')
if mail_ids[0] == "":
count1 = 0;
else:
count1 = len(mail_ids[0].split(" "))
USER = 'ZWEITER-EMAIL@NUTZERNAME'
PASSWORD = 'ZWEITES-ACCOUNT-PASSWORT'
mail = imaplib.IMAP4_SSL(IMAPSERVER)
mail.login(USER, PASSWORD)
mail.select("INBOX", True) # connect to inbox.
return_code, mail_ids = mail.search(None, 'UnSeen')
if mail_ids[0] == "":
count2 = 0;
else:
count2 = len(mail_ids[0].split(" "))
unread = count1 + count2
print unread
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment