|
Secure iNet Factory | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jscape.inet.pop.Pop
public class Pop
Implements the basic functionality of a POP3 client.
Example Usage:
// new instance with hostname, username and password Pop pop = new Pop("pop3.myserver.com","jsmith","secret"); try { // connect to POP3 server pop.connect(); // get messages Enumeration e = pop.getMessages(); while(e.hasMoreElements()) { EmailMessage em = (EmailMessage)e.nextElement(); } // disconnect pop.disconnect(); } catch(Exception e) { System.out.println(e); }
Field Summary | |
---|---|
static int |
AUTH_APOP
APOP authentication. |
static int |
AUTH_LOGIN
Standard username/password authentication. |
static int |
AUTH_PASS
Deprecated. replaced by AUTH_LOGIN variable for consistency |
Constructor Summary | |
---|---|
Pop()
Constructs a new Pop instance. |
|
Pop(java.lang.String hostname,
java.lang.String username,
java.lang.String password)
Constructs a new Pop instance. |
Method Summary | |
---|---|
void |
addPopListener(PopListener listener)
Adds Pop event listener. |
void |
clearProxySettings()
Clears proxy server values. |
void |
connect()
Connects to POP3 server and performs login. |
void |
deleteMessage(int msg)
Deletes message from POP3 server. |
void |
disconnect()
Disconnects from POP3 server. |
int |
getAuthMode()
Gets the authentication mode used when logging into POP3 server. |
int |
getConnectTimeout()
Gets the timeout used when opening a POP3 server connection. |
java.io.PrintStream |
getDebugStream()
Gets PrintStream used in reporting debug statements. |
java.lang.String |
getHostname()
Gets the hostname of the POP3 server. |
EmailMessage |
getMessage(int msg)
Gets message from POP3 server. |
int |
getMessageCount()
Gets number of messages currently in POP3 mailbox. |
PopMessageReader |
getMessageReader(int msg)
Gets a reader that may be used to read message. |
java.util.Enumeration |
getMessages()
Gets all available messages in mailbox from POP3 server. |
int |
getMessageSize(int msg)
Gets size of message in bytes from POP3 server. |
int |
getPort()
Gets the port of the POP3 server. |
int |
getReadTimeout()
Gets the timeout used when reading responses from POP server. |
int |
getTimeout()
Deprecated. Replaced by getConnectTimeout and getReadTimeout |
java.lang.String |
getTop(int msg,
int lines)
Gets summary of message from POP3 server. |
java.lang.String |
getUid(int msg)
Gets unique message id for a message on POP3 server. |
java.lang.String |
getUsername()
Gets the username to be used in authentication to POP3 server. |
boolean |
isConnected()
Checks if client is connected to POP3 server. |
boolean |
isDebug()
Gets debug level of POP3 session. |
boolean |
isDelete()
Checks whether to delete messages automatically after retrieval. |
java.lang.String |
issueCommand(java.lang.String command)
Issues a command to POP3 server and reads response. |
java.lang.String |
issueCommand(java.lang.String command,
boolean readResponse)
Issues a command to POP3 server and optionally reads response. |
java.lang.String |
issueCommandMultiLine(java.lang.String command)
Issues a command to POP3 server and reads a multi-line response. |
void |
removePopListener(PopListener listener)
Removes specified Pop event listener. |
void |
setAuthMode(int mode)
Sets the authentication mode used when logging into POP3 server. |
void |
setConnectTimeout(int timeout)
Sets the timeout for opening a POP3 server connection. |
void |
setDebug(boolean debug)
Sets debugging state. |
void |
setDebugStream(java.io.PrintStream debugStream)
Sets PrintStream used in reporting debug statements. |
void |
setDelete(boolean delete)
Defines whether to delete messages automatically after retrieval. |
void |
setHostname(java.lang.String hostname)
Sets the hostname of the POP3 server. |
void |
setPassword(java.lang.String password)
Sets the password to be used in authentication to POP3 server. |
void |
setPort(int port)
Sets the port of the POP3 server. |
void |
setProxyAuthentication(java.lang.String proxyUsername,
java.lang.String proxyPassword)
Sets the username and password to use when for authentication with proxy server. |
void |
setProxyHost(java.lang.String proxyHostname,
int proxyPort)
Sets the proxy hostname and port for this connection. |
void |
setProxyType(java.lang.String proxyType)
Sets the proxy type will be used for this connection. |
void |
setReadTimeout(int timeout)
Sets the timeout for reading responses from POP server. |
void |
setTimeout(int timeout)
Deprecated. Replaced by setConnectTimeout and setReadTimeout |
void |
setUsername(java.lang.String username)
Sets the username to be used in authentication to POP3 server. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int AUTH_PASS
setAuthMode
method.
public static final int AUTH_LOGIN
setAuthMode
method.
public static final int AUTH_APOP
setAuthMode
method.
Constructor Detail |
---|
public Pop()
public Pop(java.lang.String hostname, java.lang.String username, java.lang.String password)
hostname
- the hostname of POP3 serverusername
- the username of POP3 userpassword
- the password of POP3 userMethod Detail |
---|
public void setAuthMode(int mode)
mode
- authentication modepublic int getAuthMode()
public void setConnectTimeout(int timeout)
timeout
- the timeout in millisecondspublic int getConnectTimeout()
public boolean isConnected()
public void setDebug(boolean debug)
debug
- true
to turn debugging onsetDebugStream(java.io.PrintStream)
public boolean isDebug()
true
if debugging is onsetDebugStream(java.io.PrintStream)
public void setDebugStream(java.io.PrintStream debugStream)
debugStream
- the PrintStream to send debug statements toPrintStream
public java.io.PrintStream getDebugStream()
PrintStream
public void setDelete(boolean delete)
false
.
delete
- true
to delete automaticallypublic boolean isDelete()
false
.
true
if should delete automaticallypublic void setHostname(java.lang.String hostname)
hostname
- the hostname of POP3 serverpublic java.lang.String getHostname()
public EmailMessage getMessage(int msg) throws PopException
msg
- message id of message
PopException
- if I/O or POP3 related error occursEmailMessage
public int getMessageCount() throws PopException
PopException
- if I/O or POP3 related error occurspublic PopMessageReader getMessageReader(int msg) throws PopException
msg
- the message id of message
PopException
- if an I/O or POP3 related error occurs.PopMessageReader
public int getMessageSize(int msg) throws PopException
msg
- message id of message
PopException
- if I/O or POP3 related error occurspublic java.util.Enumeration getMessages() throws PopException
PopException
- if I/O or POP3 related error occursEmailMessage
public void setPassword(java.lang.String password)
password
- the password of POP3 userpublic void setPort(int port)
port
- the port of POP3 serverpublic int getPort()
public void setReadTimeout(int timeout)
timeout
- the timeout in millisecondspublic int getReadTimeout()
public void setTimeout(int timeout)
timeout
- the timeout in millisecondssetConnectTimeout(int)
,
setReadTimeout(int)
public int getTimeout()
getConnectTimeout()
,
getReadTimeout()
public java.lang.String getTop(int msg, int lines) throws PopException
msg
- message idlines
- number of lines to retrieve
PopException
- if I/O or POP3 related error occurspublic java.lang.String getUid(int msg) throws PopException
msg
- the message number to get the unique message id for. Message number is always (1)
based, first message number is 1, second is 2 and so on.
PopException
- if an I/O or POP3 related error occurspublic void setUsername(java.lang.String username)
username
- the username of POP3 userpublic java.lang.String getUsername()
public void setProxyAuthentication(java.lang.String proxyUsername, java.lang.String proxyPassword)
#clearProxySettings
method.
proxyUsername
- the proxy usernameproxyPassword
- the proxy passwordclearProxySettings()
public void setProxyHost(java.lang.String proxyHostname, int proxyPort)
#clearProxySettings
method.
proxyHostname
- the hostname or ip address of the proxy serverproxyPort
- the port of the proxy serverclearProxySettings()
public void setProxyType(java.lang.String proxyType)
proxyType
- The proxy type. Valid values: HTTP, SOCKS5public void clearProxySettings()
public void addPopListener(PopListener listener)
listener
- a PopListenerPopListener
public void connect() throws PopException
PopException
- if I/O or POP3 related error occurspublic void deleteMessage(int msg) throws PopException
msg
- message id of message
PopException
- if I/O or POP3 related error occurspublic void disconnect() throws PopException
PopException
- if I/O or POP3 related error occurspublic java.lang.String issueCommand(java.lang.String command) throws PopException
command
- a POP3 command
PopException
- if I/O or POP3 related error occurspublic java.lang.String issueCommand(java.lang.String command, boolean readResponse) throws PopException
command
- a POP3 commandreadResponse
- true
if should read response
false
otherwise
PopException
- if I/O or POP3 related error occurspublic java.lang.String issueCommandMultiLine(java.lang.String command) throws PopException
command
- a POP3 command
PopException
- if I/O or POP3 related error occurspublic void removePopListener(PopListener listener)
listener
- the PopListener to removePopListener
|
Secure iNet Factory | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |