📄 com.jthomas.pop.pop3.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<!--NewPage-->
<html>
<head>
<!-- Generated by javadoc on Wed Sep 02 08:05:40 GMT+00:00 1998 -->
<title>
Class com.jthomas.pop.pop3
</title>
</head>
<body>
<a name="_top_"></a>
<pre>
<a href="packages.html">All Packages</a> <a href="tree.html">Class Hierarchy</a> <a href="Package-com.jthomas.pop.html">This Package</a> <a href="com.jthomas.pop.apop.html#_top_">Previous</a> <a href="com.jthomas.pop.popStatus.html#_top_">Next</a> <a href="AllNames.html">Index</a></pre>
<hr>
<h1>
Class com.jthomas.pop.pop3
</h1>
<pre>
java.lang.Object
|
+----com.jthomas.pop.pop3
</pre>
<hr>
<dl>
<dt> public class <b>pop3</b>
<dt> extends Object
</dl>
<p>Get the latest version of this and other classes in <a href="http://www.geocities.com/SunsetStrip/Studio/4994/java.html"> Stefano Locati's Java page.</a> <p>Interface to a POP3 mail server. Can be used to check, fetch and delete mail messages. Based on the <a href="http://ds.internic.net/rfc/rfc1939.txt">rfc1939.txt</a> definition for the Post Office Protocol - Version 3 (obsoletes RFC 1725). <b>If mailhost, user, password are not supplied to the constructor, then they must be specified on the connect and login calls.</b> <p>The <code>APOP</code> command is not supported by the <code>pop3</code> class. But there is an <code>apop</code> class that extends <code>pop3</code> to add <code>APOP</code> support. It can be used just like the pop class, just create an apop object instead a pop object. The apop class still works even if the <code>POP3</code> server doesn't support <code>APOP</code> login. <p>Simple Usage Example to display the size of each message. <pre> pop3 pop = new pop3(host, user, password); popStatus status = pop.connect(); if ( status.OK() ) status = pop.login(); if ( status.OK() ) { status = pop.list(); String[] responses = status.Responses(); for(int i=0; i< responses.length; i++) { System.out.println("Message[" + i + "]='" + responses[i] + "'"); } status = pop.quit(); } </pre> <p>The following methods try to closely implement the corresponding POP3 server commands. See RFC1939. <pre> popStatus stat() popStatus list() popStatus list(msgnum) popStatus retr(msgnum) popStatus dele(msgnum) popStatus noop() popStatus quit() popStatus top(msgnum,numlines) popStatus uidl(msgnum) </pre> <ul><li>The indicated methods have additional multiline output that can be retrieved with the get_Responses method for the popStatus object. i.e. <pre> popStatus status = mypopserver.list() String[] list = status.get_Responses() </pre> <li>The following methods are convenience functions for the client <pre> popStatus appendFile(filename,msgnum) int get_TotalMsgs() Number of mail messages on server int get_TotalSize() Total size of all mail messages _TotalSize and _TotalMsgs are set during login() by an internal stat() command </pre> <li>The status of a POP request is returned in an instance of the popStatus class. popStatus has the following methods to extract the returned info. <pre> boolean OK() True if request had no errors String Response() The initial line returned by POP server that starts with either +OK or -ERR String[] Responses() If command returns multiple lines of data (RETR, TOP, LIST) then this method will return the lines in an array. </pre> <li>Public debugging Methods. <pre> void setDebugOn(boolean) turn on debug output void set_DebugFile(filename) Set filename for debug output void debug(String DebugInfo) Display string on stdout </pre> </ul>
<p>
<dl>
<dt> <b>Version:</b>
<dd> $Revision: 1.13 $ $Date: 1998/09/02 08:05:29 $
<dt> <b>Author:</b>
<dd> <b>Original author:</b> John Thomas <a href="mailto:jthomas@cruzio.com">jthomas@cruzio.com</a>, <b>Current maintainer:</b> Stefano Locati <a href="mailto:slocati@geocities.com">slocati@geocities.com</a> or <a href="mailto:stefano.locati@usa.net">stefano.locati@usa.net</a>
<dt> <b>See Also:</b>
<dd> <a href="com.jthomas.pop.apop.html#_top_">apop</a>
</dl>
<hr>
<a name="index"></a>
<h2>
<img src="images/variable-index.gif" width=207 height=38 alt="Variable Index">
</h2>
<dl>
<dt> <img src="images/magenta-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#_StatusOK"><b>_StatusOK</b></a>
<dd> status used by Send/Recv
<dt> <img src="images/magenta-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#_TotalMsgs"><b>_TotalMsgs</b></a>
<dd> Number of mail messages on server
<dt> <img src="images/magenta-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#_TotalSize"><b>_TotalSize</b></a>
<dd> Total size of all messages on server
<dt> <img src="images/magenta-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#AUTHORIZATION"><b>AUTHORIZATION</b></a>
<dd> Authorization State
<dt> <img src="images/magenta-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#Host"><b>Host</b></a>
<dd> POP3 server host name
<dt> <img src="images/magenta-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#LastCmd"><b>LastCmd</b></a>
<dd> The last POP3 command sent to the server
<dt> <img src="images/magenta-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#Password"><b>Password</b></a>
<dd> Mailbox password
<dt> <img src="images/magenta-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#Port"><b>Port</b></a>
<dd> Port on which the POP3 server listens to
<dt> <img src="images/magenta-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#server"><b>server</b></a>
<dd> Socket connected to the server
<dt> <img src="images/magenta-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#serverInputStream"><b>serverInputStream</b></a>
<dd> Input stream connected to the server socket
<dt> <img src="images/magenta-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#serverOutputStream"><b>serverOutputStream</b></a>
<dd> Output stream connected to the server socket
<dt> <img src="images/magenta-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#State"><b>State</b></a>
<dd> Session State
<dt> <img src="images/magenta-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#TRANSACTION"><b>TRANSACTION</b></a>
<dd> Transaction State
<dt> <img src="images/magenta-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#UPDATE"><b>UPDATE</b></a>
<dd> Update State
<dt> <img src="images/magenta-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#User"><b>User</b></a>
<dd> Mailbox user name
</dl>
<h2>
<img src="images/constructor-index.gif" width=275 height=38 alt="Constructor Index">
</h2>
<dl>
<dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#pop3()"><b>pop3</b></a>()
<dd> Creates the object.
<dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#pop3(java.lang.String, java.lang.String, java.lang.String)"><b>pop3</b></a>(String, String, String)
<dd> Creates the object.
</dl>
<h2>
<img src="images/method-index.gif" width=207 height=38 alt="Method Index">
</h2>
<dl>
<dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#appendFile(java.lang.String, int)"><b>appendFile</b></a>(String, int)
<dd> Returns the contents of a mail message and append it to the specified mail file.
<dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#close()"><b>close</b></a>()
<dd> Closes the socket connection.
<dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#connect()"><b>connect</b></a>()
<dd> Makes a socket connection to the host specified in the constructor (port 110).
<dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#connect(java.lang.String)"><b>connect</b></a>(String)
<dd> Makes a socket connection to the specified host (port 110).
<dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#connect(java.lang.String, int)"><b>connect</b></a>(String, int)
<dd> Makes a socket connection to the specified host and port.
<dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#debug(java.lang.String)"><b>debug</b></a>(String)
<dd> If debugOn switch is set, display debug info.
<dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#dele(int)"><b>dele</b></a>(int)
<dd> Marks the mail message for deletion This mail message will be deleted when QUIT is issued.
<dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#get_TotalMsgs()"><b>get_TotalMsgs</b></a>()
<dd> Returns the number of messages on the server.
<dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#get_TotalSize()"><b>get_TotalSize</b></a>()
<dd> Returns the size of messages on the server.
<dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#list()"><b>list</b></a>()
<dd> Gets a list of messages and the size of each one.
<dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#list(int)"><b>list</b></a>(int)
<dd> Gets the size of the specified mail message.
<dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#login()"><b>login</b></a>()
<dd> Login with the user and password specified in the constructor.<br> If the login is successful, a <code>STAT</code> command is issued to get the current number of messages.
<dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#login(java.lang.String, java.lang.String)"><b>login</b></a>(String, String)
<dd> Login the specified user with the specified password.<br> If the login is successful, a "STAT" command is issued to get the current number of messages.
<dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#noop()"><b>noop</b></a>()
<dd> Does not do anything but it will keep the server active.
<dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#quit()"><b>quit</b></a>()
<dd> Quits the session with the POP3 server.
<dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#retr(int)"><b>retr</b></a>(int)
<dd> Gets the contents of a mail message.
<dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#rset()"><b>rset</b></a>()
<dd> Resets the mail messages that have been marked for deletion.
<dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#setDebugOn(boolean)"><b>setDebugOn</b></a>(boolean)
<dd> Sets debug on or off.
<dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#stat()"><b>stat</b></a>()
<dd> Gets the number of messages and their total size from the server.
<dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#top(int, int)"><b>top</b></a>(int, int)
<dd> Gets the top n lines of a mail message.
<dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#uidl()"><b>uidl</b></a>()
<dd> Gets a list of messages and the <code>UIDL</code> of each one.
<dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
<a href="#uidl(int)"><b>uidl</b></a>(int)
<dd> Gets the uidl of the specified mail msg.
</dl>
<a name="variables"></a>
<h2>
<img src="images/variables.gif" width=153 height=38 alt="Variables">
</h2>
<a name="AUTHORIZATION"><img src="images/magenta-ball.gif" width=12 height=12 alt=" o "></a>
<b>AUTHORIZATION</b>
<pre>
protected final int AUTHORIZATION
</pre>
<dl>
<dd> Authorization State<p>
</dl>
<a name="TRANSACTION"><img src="images/magenta-ball.gif" width=12 height=12 alt=" o "></a>
<b>TRANSACTION</b>
<pre>
protected final int TRANSACTION
</pre>
<dl>
<dd> Transaction State<p>
</dl>
<a name="UPDATE"><img src="images/magenta-ball.gif" width=12 height=12 alt=" o "></a>
<b>UPDATE</b>
<pre>
protected final int UPDATE
</pre>
<dl>
<dd> Update State<p>
</dl>
<a name="_TotalMsgs"><img src="images/magenta-ball.gif" width=12 height=12 alt=" o "></a>
<b>_TotalMsgs</b>
<pre>
protected int _TotalMsgs
</pre>
<dl>
<dd> Number of mail messages on server<p>
</dl>
<a name="_TotalSize"><img src="images/magenta-ball.gif" width=12 height=12 alt=" o "></a>
<b>_TotalSize</b>
<pre>
protected int _TotalSize
</pre>
<dl>
<dd> Total size of all messages on server<p>
</dl>
<a name="_StatusOK"><img src="images/magenta-ball.gif" width=12 height=12 alt=" o "></a>
<b>_StatusOK</b>
<pre>
protected boolean _StatusOK
</pre>
<dl>
<dd> status used by Send/Recv<p>
</dl>
<a name="State"><img src="images/magenta-ball.gif" width=12 height=12 alt=" o "></a>
<b>State</b>
<pre>
protected int State
</pre>
<dl>
<dd> Session State<p>
</dl>
<a name="LastCmd"><img src="images/magenta-ball.gif" width=12 height=12 alt=" o "></a>
<b>LastCmd</b>
<pre>
protected String LastCmd
</pre>
<dl>
<dd> The last POP3 command sent to the server<p>
</dl>
<a name="Host"><img src="images/magenta-ball.gif" width=12 height=12 alt=" o "></a>
<b>Host</b>
<pre>
protected String Host
</pre>
<dl>
<dd> POP3 server host name<p>
</dl>
<a name="Port"><img src="images/magenta-ball.gif" width=12 height=12 alt=" o "></a>
<b>Port</b>
<pre>
protected int Port
</pre>
<dl>
<dd> Port on which the POP3 server listens to<p>
</dl>
<a name="User"><img src="images/magenta-ball.gif" width=12 height=12 alt=" o "></a>
<b>User</b>
<pre>
protected String User
</pre>
<dl>
<dd> Mailbox user name<p>
</dl>
<a name="Password"><img src="images/magenta-ball.gif" width=12 height=12 alt=" o "></a>
<b>Password</b>
<pre>
protected String Password
</pre>
<dl>
<dd> Mailbox password<p>
</dl>
<a name="server"><img src="images/magenta-ball.gif" width=12 height=12 alt=" o "></a>
<b>server</b>
<pre>
protected Socket server
</pre>
<dl>
<dd> Socket connected to the server<p>
</dl>
<a name="serverInputStream"><img src="images/magenta-ball.gif" width=12 height=12 alt=" o "></a>
<b>serverInputStream</b>
<pre>
protected BufferedReader serverInputStream
</pre>
<dl>
<dd> Input stream connected to the server socket<p>
</dl>
<a name="serverOutputStream"><img src="images/magenta-ball.gif" width=12 height=12 alt=" o "></a>
<b>serverOutputStream</b>
<pre>
protected DataOutputStream serverOutputStream
</pre>
<dl>
<dd> Output stream connected to the server socket<p>
</dl>
<a name="constructors"></a>
<h2>
<img src="images/constructors.gif" width=231 height=38 alt="Constructors">
</h2>
<a name="pop3"></a>
<a name="pop3(java.lang.String, java.lang.String, java.lang.String)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>pop3</b>
<pre>
public pop3(String host,
String user,
String password)
</pre>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -