BackBox Indonesia
Checking Imap With Python - Printable Version

+- BackBox Indonesia (https://www.backboxindonesia.or.id)
+-- Forum: Coding (https://www.backboxindonesia.or.id/forum-31.html)
+--- Forum: Python (https://www.backboxindonesia.or.id/forum-35.html)
+--- Thread: Checking Imap With Python (/thread-73.html)



Checking Imap With Python - randalltux - 03-20-2016

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


RE: Checking Imap With Python - juangnakarani - 05-30-2016

eh ada kang randalltux, terima kasih kang atas scriptnya..