BackBox Indonesia

Full Version: Checking Imap With Python
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
To check the unread mail count in my IMAP account, i created a little Python sript. But because i don’t want to query the server every second, I’m caching the value in a file and update it every 30 seconds. Create a cronjob or similiar to update the file.

Code:
#!/usr/bin/env python

import imaplib

obj = imaplib.IMAP4_SSL('xxx.xxx.xxx.xxx', '993')
obj.login('user', 'password')
obj.select()
print len(obj.search(None, 'UnSeen')[1][0].split())

Originally posted on my blog
eh ada kang randalltux, terima kasih kang atas scriptnya..