poplib
index
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/poplib.py
Module Docs

POP3 client class.
 
Based on the J. Myers POP3 draft, Jan. 96

 
Modules
       
re
socket
ssl

 
Classes
       
exceptions.Exception(exceptions.BaseException)
error_proto
POP3
POP3_SSL

 
class POP3
    This class supports both the minimal and optional command sets.
Arguments can be strings or integers (where appropriate)
(e.g.: retr(1) and retr('1') both work equally well.
 
Minimal Command Set:
        USER name               user(name)
        PASS string             pass_(string)
        STAT                    stat()
        LIST [msg]              list(msg = None)
        RETR msg                retr(msg)
        DELE msg                dele(msg)
        NOOP                    noop()
        RSET                    rset()
        QUIT                    quit()
 
Optional Commands (some servers support these):
        RPOP name               rpop(name)
        APOP name digest        apop(name, digest)
        TOP msg n               top(msg, n)
        UIDL [msg]              uidl(msg = None)
 
Raises one exception: 'error_proto'.
 
Instantiate with:
        POP3(hostname, port=110)
 
NB:     the POP protocol locks the mailbox from user
        authorization until QUIT, so be sure to get in, suck
        the messages, and quit, each time you access the
        mailbox.
 
        POP is a line-based protocol, which means large mail
        messages consume lots of python cycles reading them
        line-by-line.
 
        If it's available on your mail server, use IMAP4
        instead, it doesn't suffer from the two problems
        above.
 
  Methods defined here:
__init__(self, host, port=110, timeout=<object object>)
apop(self, user, secret)
Authorisation
 
- only possible if server has supplied a timestamp in initial greeting.
 
Args:
        user    - mailbox user;
        secret  - secret shared between client and server.
 
NB: mailbox is locked by server from here to 'quit()'
dele(self, which)
Delete message number 'which'.
 
Result is 'response'.
getwelcome(self)
list(self, which=None)
Request listing, return result.
 
Result without a message number argument is in form
['response', ['mesg_num octets', ...], octets].
 
Result when a message number argument is given is a
single response: the "scan listing" for that message.
noop(self)
Does nothing.
 
One supposes the response indicates the server is alive.
pass_(self, pswd)
Send password, return response
 
(response includes message count, mailbox size).
 
NB: mailbox is locked by server from here to 'quit()'
quit(self)
Signoff: commit changes on server, unlock mailbox, close connection.
retr(self, which)
Retrieve whole message number 'which'.
 
Result is in form ['response', ['line', ...], octets].
rpop(self, user)
Not sure what this does.
rset(self)
Unmark all messages marked for deletion.
set_debuglevel(self, level)
stat(self)
Get mailbox status.
 
Result is tuple of 2 ints (message count, mailbox size)
top(self, which, howmuch)
Retrieve message header of message number 'which'
and first 'howmuch' lines of message body.
 
Result is in form ['response', ['line', ...], octets].
uidl(self, which=None)
Return message digest (unique id) list.
 
If 'which', result contains unique id for that message
in the form 'response mesgnum uid', otherwise result is
the list ['response', ['mesgnum uid', ...], octets]
user(self, user)
Send user name, return response
 
(should indicate password required).

Data and other attributes defined here:
timestamp = <_sre.SRE_Pattern object>

 
class POP3_SSL(POP3)
    POP3 client class over SSL connection
 
Instantiate with: POP3_SSL(hostname, port=995, keyfile=None, certfile=None)
 
       hostname - the hostname of the pop3 over ssl server
       port - port number
       keyfile - PEM formatted file that contains your private key
       certfile - PEM formatted certificate chain file
 
    See the methods of the parent class POP3 for more documentation.
 
  Methods defined here:
__init__(self, host, port=995, keyfile=None, certfile=None)
quit(self)
Signoff: commit changes on server, unlock mailbox, close connection.

Methods inherited from POP3:
apop(self, user, secret)
Authorisation
 
- only possible if server has supplied a timestamp in initial greeting.
 
Args:
        user    - mailbox user;
        secret  - secret shared between client and server.
 
NB: mailbox is locked by server from here to 'quit()'
dele(self, which)
Delete message number 'which'.
 
Result is 'response'.
getwelcome(self)
list(self, which=None)
Request listing, return result.
 
Result without a message number argument is in form
['response', ['mesg_num octets', ...], octets].
 
Result when a message number argument is given is a
single response: the "scan listing" for that message.
noop(self)
Does nothing.
 
One supposes the response indicates the server is alive.
pass_(self, pswd)
Send password, return response
 
(response includes message count, mailbox size).
 
NB: mailbox is locked by server from here to 'quit()'
retr(self, which)
Retrieve whole message number 'which'.
 
Result is in form ['response', ['line', ...], octets].
rpop(self, user)
Not sure what this does.
rset(self)
Unmark all messages marked for deletion.
set_debuglevel(self, level)
stat(self)
Get mailbox status.
 
Result is tuple of 2 ints (message count, mailbox size)
top(self, which, howmuch)
Retrieve message header of message number 'which'
and first 'howmuch' lines of message body.
 
Result is in form ['response', ['line', ...], octets].
uidl(self, which=None)
Return message digest (unique id) list.
 
If 'which', result contains unique id for that message
in the form 'response mesgnum uid', otherwise result is
the list ['response', ['mesgnum uid', ...], octets]
user(self, user)
Send user name, return response
 
(should indicate password required).

Data and other attributes inherited from POP3:
timestamp = <_sre.SRE_Pattern object>

 
class error_proto(exceptions.Exception)
    
Method resolution order:
error_proto
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors defined here:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see help(type(x)) for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)
__unicode__(...)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message

 
Data
        __all__ = ['POP3', 'error_proto', 'POP3_SSL']