poplib.POP3

class poplib.POP3(host, port=110, timeout=<object object>)[source]

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

__init__(host[, port, timeout])
_getline()
_getlongresp()
_getresp()
_longcmd(line)
_putcmd(line)
_putline(line)
_shortcmd(line)
apop(user, secret) Authorisation
dele(which) Delete message number ‘which’.
getwelcome()
list([which]) Request listing, return result.
noop() Does nothing.
pass_(pswd) Send password, return response
quit() Signoff: commit changes on server, unlock mailbox, close connection.
retr(which) Retrieve whole message number ‘which’.
rpop(user) Not sure what this does.
rset() Unmark all messages marked for deletion.
set_debuglevel(level)
stat() Get mailbox status.
top(which, howmuch) Retrieve message header of message number ‘which’ and first ‘howmuch’ lines of message body.
uidl([which]) Return message digest (unique id) list.
user(user) Send user name, return response

Attributes

timestamp