July 16, 2010 at 6:05 pm | PROGRAMMING, PYTHON | 1 comment
The python-imaplib module defines three classes, IMAP4, IMAP4_SSL and IMAP4_stream, which encapsulate a connection to an IMAP4 server and implement a large subset of the IMAP4rev1 client protocol as defined in RFC 2060.
Here’s a code sample that returns your gmail quota details.
import getpass, imaplib, re p = re.compile('\d+') IMAP_SERVER='imap.gmail.com' IMAP_PORT=993 IMAP_USERNAME='username@gmail.com' M = imaplib.IMAP4_SSL(IMAP_SERVER, IMAP_PORT) M.login(IMAP_USERNAME, getpass.getpass()) quotaStr = M.getquotaroot("INBOX")[1][1][0] r = p.findall(quotaStr) if r == []: print "Unlimited Quota Account" r.append(0) r.append(0) print 'Allotted = %f MB'%(float(r[1])/1024) print 'Used = %f MB'%(float(r[0])/1024) M.logout()
The script will ask your gmail password and the output will be something like this:
Allotted = 7476.760000 MB Used = 961.390000 MB
Related posts:
[...] more: Check Your IMAP Quota Using Python Imaplib | segfault.in IMAP, module-defines, python, ratings, stars, [...]