-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunread.py
More file actions
executable file
·27 lines (18 loc) · 779 Bytes
/
Copy pathunread.py
File metadata and controls
executable file
·27 lines (18 loc) · 779 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/python
## change YOUR* pseudo-variables according to your needs
import imaplib
# import commands
import subprocess
login_proc = subprocess.Popen(["/home/dionisos/scripts/.psw", "-u", "gmail"], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
password_proc = subprocess.Popen(["/home/dionisos/scripts/.psw", "-p", "gmail"], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
login = login_proc.stdout.read().decode("utf-8")
password = password_proc.stdout.read().decode("utf-8")
#default imap port is 993, change otherwise
M=imaplib.IMAP4_SSL("imap.gmail.com", 993)
M.login(login, password)
status, counts = M.status("Inbox","(MESSAGES UNSEEN)")
unread = counts[0].split()[4][:-1]
print(int(unread))
M.logout()