Previous: 11.9.1 POP3 Objects Up: 11.9 poplib Next: 11.10 imaplib


11.9.2 POP3 Example

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

import getpass, poplib
M = poplib.POP3('localhost')
M.user(getpass.getuser())
M.pass_(getpass.getpass())
numMessages = len(M.list()[1])
for i in range(numMessages):
 for j in M.retr(i+1)[1]:
 print j

At the end of the module, there is a test section that contains a more extensive example of usage.


Previous: 11.9.1 POP3 Objects Up: 11.9 poplib Next: 11.10 imaplib
Release 2.2.3, documentation updated on 30 May 2003.
See About this document... for information on suggesting changes.

AltStyle によって変換されたページ (->オリジナル) /