<!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN">
<link rel=
"STYLESHEET" href=
"lib.css" type='text/css'
/>
<link rel=
"SHORTCUT ICON" href=
"../icons/pyfav.png" type=
"image/png" />
<link rel='start' href='../index.html' title='Python Documentation Index'
/>
<link rel=
"first" href=
"lib.html" title='Python Library Reference'
/>
<link rel='contents' href='contents.html'
title=
"Contents" />
<link rel='index' href='genindex.html' title='Index'
/>
<link rel='last' href='about.html' title='About this document...'
/>
<link rel='help' href='about.html' title='About this document...'
/>
<link rel=
"next" href=
"pop3-example.html" />
<link rel=
"prev" href=
"module-poplib.html" />
<link rel=
"parent" href=
"module-poplib.html" />
<link rel=
"next" href=
"pop3-example.html" />
<meta name='aesop' content='information'
/>
<title>11.9.1 POP3 Objects
</title>
<div id='top-navigation-panel' xml:id='top-navigation-panel'
>
<table align=
"center" width=
"100%" cellpadding=
"0" cellspacing=
"2">
<td class='online-navigation'
><a rel=
"prev" title=
"11.9 poplib "
href=
"module-poplib.html"><img src='../icons/previous.png'
border='
0' height='
32' alt='Previous Page' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"parent" title=
"11.9 poplib "
href=
"module-poplib.html"><img src='../icons/up.png'
border='
0' height='
32' alt='Up One Level' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"next" title=
"11.9.2 POP3 Example"
href=
"pop3-example.html"><img src='../icons/next.png'
border='
0' height='
32' alt='Next Page' width='
32'
/></A></td>
<td align=
"center" width=
"100%">Python Library Reference
</td>
<td class='online-navigation'
><a rel=
"contents" title=
"Table of Contents"
href=
"contents.html"><img src='../icons/contents.png'
border='
0' height='
32' alt='Contents' width='
32'
/></A></td>
<td class='online-navigation'
><a href=
"modindex.html" title=
"Module Index"><img src='../icons/modules.png'
border='
0' height='
32' alt='Module Index' width='
32'
/></a></td>
<td class='online-navigation'
><a rel=
"index" title=
"Index"
href=
"genindex.html"><img src='../icons/index.png'
border='
0' height='
32' alt='Index' width='
32'
/></A></td>
<div class='online-navigation'
>
<b class=
"navlabel">Previous:
</b>
<a class=
"sectref" rel=
"prev" href=
"module-poplib.html">11.9 poplib
</A>
<b class=
"navlabel">Up:
</b>
<a class=
"sectref" rel=
"parent" href=
"module-poplib.html">11.9 poplib
</A>
<b class=
"navlabel">Next:
</b>
<a class=
"sectref" rel=
"next" href=
"pop3-example.html">11.9.2 POP3 Example
</A>
<!--End of Navigation Panel-->
<H2><A NAME=
"SECTION0013910000000000000000"></A><A NAME=
"pop3-objects"></A>
All POP3 commands are represented by methods of the same name,
in lower-case; most return the response text sent by the server.
An
<tt class=
"class">POP3
</tt> instance has the following methods:
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
3376' xml:id='l2h-
3376'
class=
"method">set_debuglevel
</tt></b>(
</nobr></td>
<td><var>level
</var>)
</td></tr></table></dt>
Set the instance's debugging level. This controls the amount of
debugging output printed. The default,
<code>0</code>, produces no
debugging output. A value of
<code>1</code> produces a moderate amount of
debugging output, generally a single line per request. A value of
<code>2</code> or higher produces the maximum amount of debugging output,
logging each line sent and received on the control connection.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
3377' xml:id='l2h-
3377'
class=
"method">getwelcome
</tt></b>(
</nobr></td>
<td><var></var>)
</td></tr></table></dt>
Returns the greeting string sent by the POP3 server.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
3378' xml:id='l2h-
3378'
class=
"method">user
</tt></b>(
</nobr></td>
<td><var>username
</var>)
</td></tr></table></dt>
Send user command, response should indicate that a password is required.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
3379' xml:id='l2h-
3379'
class=
"method">pass_
</tt></b>(
</nobr></td>
<td><var>password
</var>)
</td></tr></table></dt>
Send password, response includes message count and mailbox size.
Note: the mailbox on the server is locked until
<tt class=
"method">quit()
</tt> is
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
3380' xml:id='l2h-
3380'
class=
"method">apop
</tt></b>(
</nobr></td>
<td><var>user, secret
</var>)
</td></tr></table></dt>
Use the more secure APOP authentication to log into the POP3 server.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
3381' xml:id='l2h-
3381'
class=
"method">rpop
</tt></b>(
</nobr></td>
<td><var>user
</var>)
</td></tr></table></dt>
Use RPOP authentication (similar to UNIX r-commands) to log into POP3 server.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
3382' xml:id='l2h-
3382'
class=
"method">stat
</tt></b>(
</nobr></td>
<td><var></var>)
</td></tr></table></dt>
Get mailbox status. The result is a tuple of
2 integers:
<code>(
<var>message count
</var>,
<var>mailbox size
</var>)
</code>.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
3383' xml:id='l2h-
3383'
class=
"method">list
</tt></b>(
</nobr></td>
<td><var></var><big>[
</big><var>which
</var><big>]
</big><var></var>)
</td></tr></table></dt>
Request message list, result is in the form
<code>(
<var>response
</var>, ['mesg_num octets', ...],
<var>octets
</var>)
</code>.
If
<var>which
</var> is set, it is the message to list.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
3384' xml:id='l2h-
3384'
class=
"method">retr
</tt></b>(
</nobr></td>
<td><var>which
</var>)
</td></tr></table></dt>
Retrieve whole message number
<var>which
</var>, and set its seen flag.
Result is in form
<code>(
<var>response
</var>, ['line', ...],
<var>octets
</var>)
</code>.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
3385' xml:id='l2h-
3385'
class=
"method">dele
</tt></b>(
</nobr></td>
<td><var>which
</var>)
</td></tr></table></dt>
Flag message number
<var>which
</var> for deletion. On most servers
deletions are not actually performed until QUIT (the major exception is
Eudora QPOP, which deliberately violates the RFCs by doing pending
deletes on any disconnect).
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
3386' xml:id='l2h-
3386'
class=
"method">rset
</tt></b>(
</nobr></td>
<td><var></var>)
</td></tr></table></dt>
Remove any deletion marks for the mailbox.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
3387' xml:id='l2h-
3387'
class=
"method">noop
</tt></b>(
</nobr></td>
<td><var></var>)
</td></tr></table></dt>
Do nothing. Might be used as a keep-alive.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
3388' xml:id='l2h-
3388'
class=
"method">quit
</tt></b>(
</nobr></td>
<td><var></var>)
</td></tr></table></dt>
Signoff: commit changes, unlock mailbox, drop connection.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
3389' xml:id='l2h-
3389'
class=
"method">top
</tt></b>(
</nobr></td>
<td><var>which, howmuch
</var>)
</td></tr></table></dt>
Retrieves the message header plus
<var>howmuch
</var> lines of the message
after the header of message number
<var>which
</var>. Result is in form
<code>(
<var>response
</var>, ['line', ...],
<var>octets
</var>)
</code>.
The POP3 TOP command this method uses, unlike the RETR command,
doesn't set the message's seen flag; unfortunately, TOP is poorly
specified in the RFCs and is frequently broken in off-brand servers.
Test this method by hand against the POP3 servers you will use before
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><tt id='l2h-
3390' xml:id='l2h-
3390'
class=
"method">uidl
</tt></b>(
</nobr></td>
<td><var></var><big>[
</big><var>which
</var><big>]
</big><var></var>)
</td></tr></table></dt>
Return message digest (unique id) list.
If
<var>which
</var> is specified, result contains the unique id for that
message in the form
<code>'
<var>response
</var> <var>mesgnum
</var> <var>uid
</var></code>,
otherwise result is list
<code>(
<var>response
</var>, ['mesgnum uid', ...],
<var>octets
</var>)
</code>.
Instances of
<tt class=
"class">POP3_SSL
</tt> have no additional methods. The
interface of this subclass is identical to its parent.
<div class='online-navigation'
>
<table align=
"center" width=
"100%" cellpadding=
"0" cellspacing=
"2">
<td class='online-navigation'
><a rel=
"prev" title=
"11.9 poplib "
href=
"module-poplib.html"><img src='../icons/previous.png'
border='
0' height='
32' alt='Previous Page' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"parent" title=
"11.9 poplib "
href=
"module-poplib.html"><img src='../icons/up.png'
border='
0' height='
32' alt='Up One Level' width='
32'
/></A></td>
<td class='online-navigation'
><a rel=
"next" title=
"11.9.2 POP3 Example"
href=
"pop3-example.html"><img src='../icons/next.png'
border='
0' height='
32' alt='Next Page' width='
32'
/></A></td>
<td align=
"center" width=
"100%">Python Library Reference
</td>
<td class='online-navigation'
><a rel=
"contents" title=
"Table of Contents"
href=
"contents.html"><img src='../icons/contents.png'
border='
0' height='
32' alt='Contents' width='
32'
/></A></td>
<td class='online-navigation'
><a href=
"modindex.html" title=
"Module Index"><img src='../icons/modules.png'
border='
0' height='
32' alt='Module Index' width='
32'
/></a></td>
<td class='online-navigation'
><a rel=
"index" title=
"Index"
href=
"genindex.html"><img src='../icons/index.png'
border='
0' height='
32' alt='Index' width='
32'
/></A></td>
<div class='online-navigation'
>
<b class=
"navlabel">Previous:
</b>
<a class=
"sectref" rel=
"prev" href=
"module-poplib.html">11.9 poplib
</A>
<b class=
"navlabel">Up:
</b>
<a class=
"sectref" rel=
"parent" href=
"module-poplib.html">11.9 poplib
</A>
<b class=
"navlabel">Next:
</b>
<a class=
"sectref" rel=
"next" href=
"pop3-example.html">11.9.2 POP3 Example
</A>
<span class=
"release-info">Release
2.4.2, documentation updated on
28 September
2005.
</span>
<!--End of Navigation Panel-->
See
<i><a href=
"about.html">About this document...
</a></i> for information on suggesting changes.