GNU Info

Info Node: (python2.1-lib.info)IMAP4 Example

(python2.1-lib.info)IMAP4 Example


Prev: IMAP4 Objects Up: imaplib
Enter node , (file) or (file)node

IMAP4 Example
-------------

Here is a minimal example (without error checking) that opens a mailbox
and retrieves and prints all messages:

     import getpass, imaplib, string
     
     M = imaplib.IMAP4()
     M.login(getpass.getuser(), getpass.getpass())
     M.select()
     typ, data = M.search(None, 'ALL')
     for num in string.split(data[0]):
         typ, data = M.fetch(num, '(RFC822)')
         print 'Message %s\n%s\n' % (num, data[0][1])
     M.logout()


automatically generated by info2www version 1.2.2.9