PyDocs

Nav

Internet Protocols and Support

POP3

poplib

class (source) not WASI
  • POP3(host, port=POP3_PORT[, timeout])
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)
        CAPA                    capa()
        STLS                    stls()
        UTF8                    utf8()

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.
Changed in 3.9
  • 3.9: If the timeout parameter is set to be zero, it will raise a ValueError to prevent the creation of a non-blocking socket.
Members of POP3

a

apop
Authorisation

c

capa
Return server capabilities (RFC 2449) as a dictionary >>> c=poplib.POP3('localhost') >>> c.capa() {'IMPLEMENTATION': ['Cyrus', 'POP3', 'server', 'v2.2.12'], 'TOP': [], 'LOGIN-DELAY': ['0'], 'AUTH-RES…

d

dele
Delete message number 'which'.

g

getwelcome
Returns the greeting string sent by the POP3 server.

l

list
Request listing, return result.

n

noop
Does nothing.

p

pass_
Send password, return response

q

quit
Signoff: commit changes on server, unlock mailbox, close connection.

r

retr
Retrieve whole message number 'which'.
rpop
Send RPOP command to access the mailbox with an alternate user.
rset
Unmark all messages marked for deletion.

s

set_debuglevel
Set the instance’s debugging level.
stat
Get mailbox status.
stls
Start a TLS session on the active connection as specified in RFC 2595.

t

top
Retrieve message header of message number 'which' and first 'howmuch' lines of message body.

u

uidl
Return message digest (unique id) list.
user
Send user name, return response
utf8
Try to enter UTF-8 mode (see RFC 6856).
0 Examples
No examples for poplib/POP3.
See Also
No see-alsos for poplib/POP3
0 Notes
No notes for POP3