| org.apache.commons.net.pop3.POP3 org.apache.commons.net.pop3.POP3Client
POP3Client | public class POP3Client extends POP3 (Code) | | The POP3Client class implements the client side of the Internet POP3
Protocol defined in RFC 1939. All commands are supported, including
the APOP command which requires MD5 encryption. See RFC 1939 for
more details on the POP3 protocol.
Rather than list it separately for each method, we mention here that
every method communicating with the server and throwing an IOException
can also throw a
org.apache.commons.net.MalformedServerReplyException , which is a subclass
of IOException. A MalformedServerReplyException will be thrown when
the reply received from the server deviates enough from the protocol
specification that it cannot be interpreted in a useful manner despite
attempts to be as lenient as possible.
author: Daniel F. Savarese See Also: POP3MessageInfo See Also: org.apache.commons.net.io.DotTerminatedMessageReader See Also: org.apache.commons.net.MalformedServerReplyException |
deleteMessage | public boolean deleteMessage(int messageId) throws IOException(Code) | | Delete a message from the POP3 server. The message is only marked
for deletion by the server. If you decide to unmark the message, you
must issuse a
POP3Client.reset reset command. Messages marked
for deletion are only deleted by the server on
POP3Client.logout logout .
A delete attempt can only succeed if the client is in the
org.apache.commons.net.pop3.POP3.TRANSACTION_STATE TRANSACTION_STATE .
Parameters: messageId - The message number to delete. True if the deletion attempt was successful, false if not. exception: IOException - If a network I/O error occurs in the process ofsending the delete command. |
listMessage | public POP3MessageInfo listMessage(int messageId) throws IOException(Code) | | List an individual message. A list attempt can only
succeed if the client is in the
org.apache.commons.net.pop3.POP3.TRANSACTION_STATE TRANSACTION_STATE . Returns a POP3MessageInfo instance
containing the number of the listed message and the
size of the message in bytes. Returns null if the list
attempt fails (e.g., if the specified message number does
not exist).
Parameters: messageId - The number of the message list. A POP3MessageInfo instance containing the number of thelisted message and the size of the message in bytes. Returnsnull if the list attempt fails. exception: IOException - If a network I/O error occurs in the process ofsending the list command. |
listMessages | public POP3MessageInfo[] listMessages() throws IOException(Code) | | List all messages. A list attempt can only
succeed if the client is in the
org.apache.commons.net.pop3.POP3.TRANSACTION_STATE TRANSACTION_STATE . Returns an array of POP3MessageInfo instances,
each containing the number of a message and its size in bytes.
If there are no messages, this method returns a zero length array.
If the list attempt fails, it returns null.
An array of POP3MessageInfo instances representing all messagesin the order they appear in the mailbox,each containing the number of a message and its size in bytes.If there are no messages, this method returns a zero length array.If the list attempt fails, it returns null. exception: IOException - If a network I/O error occurs in the process ofsending the list command. |
listUniqueIdentifier | public POP3MessageInfo listUniqueIdentifier(int messageId) throws IOException(Code) | | List the unique identifier for a message. A list attempt can only
succeed if the client is in the
org.apache.commons.net.pop3.POP3.TRANSACTION_STATE TRANSACTION_STATE . Returns a POP3MessageInfo instance
containing the number of the listed message and the
unique identifier for that message. Returns null if the list
attempt fails (e.g., if the specified message number does
not exist).
Parameters: messageId - The number of the message list. A POP3MessageInfo instance containing the number of thelisted message and the unique identifier for that message.Returns null if the list attempt fails. exception: IOException - If a network I/O error occurs in the process ofsending the list unique identifier command. |
listUniqueIdentifiers | public POP3MessageInfo[] listUniqueIdentifiers() throws IOException(Code) | | List the unique identifiers for all messages. A list attempt can only
succeed if the client is in the
org.apache.commons.net.pop3.POP3.TRANSACTION_STATE TRANSACTION_STATE . Returns an array of POP3MessageInfo instances,
each containing the number of a message and its unique identifier.
If there are no messages, this method returns a zero length array.
If the list attempt fails, it returns null.
An array of POP3MessageInfo instances representing all messagesin the order they appear in the mailbox,each containing the number of a message and its unique identifierIf there are no messages, this method returns a zero length array.If the list attempt fails, it returns null. exception: IOException - If a network I/O error occurs in the process ofsending the list unique identifier command. |
login | public boolean login(String username, String timestamp, String secret) throws IOException, NoSuchAlgorithmException(Code) | | Login to the POP3 server with the given username and authentication
information. Use this method when connecting to a server requiring
authentication using the APOP command. Because the timestamp
produced in the greeting banner varies from server to server, it is
not possible to consistently extract the information. Therefore,
after connecting to the server, you must call
org.apache.commons.net.pop3.POP3.getReplyString getReplyString and parse out the timestamp information yourself.
You must first connect to the server with
org.apache.commons.net.SocketClient.connect connect before attempting to login. A login attempt is only valid if
the client is in the
org.apache.commons.net.pop3.POP3.AUTHORIZATION_STATE AUTHORIZATION_STATE . After logging in, the client enters the
org.apache.commons.net.pop3.POP3.TRANSACTION_STATE TRANSACTION_STATE . After connecting, you must parse out the
server specific information to use as a timestamp, and pass that
information to this method. The secret is a shared secret known
to you and the server. See RFC 1939 for more details regarding
the APOP command.
Parameters: username - The account name being logged in to. Parameters: timestamp - The timestamp string to combine with the secret. Parameters: secret - The shared secret which produces the MD5 digest whencombined with the timestamp. True if the login attempt was successful, false if not. exception: IOException - If a network I/O error occurs in the process oflogging in. exception: NoSuchAlgorithmException - If the MD5 encryption algorithmcannot be instantiated by the Java runtime system. |
noop | public boolean noop() throws IOException(Code) | | Send a NOOP command to the POP3 server. This is useful for keeping
a connection alive since most POP3 servers will timeout after 10
minutes of inactivity. A noop attempt will only succeed if
the client is in the
org.apache.commons.net.pop3.POP3.TRANSACTION_STATE TRANSACTION_STATE .
True if the noop attempt was successful, false if not. exception: IOException - If a network I/O error occurs in the process ofsending the NOOP command. |
reset | public boolean reset() throws IOException(Code) | | Reset the POP3 session. This is useful for undoing any message
deletions that may have been performed. A reset attempt can only
succeed if the client is in the
org.apache.commons.net.pop3.POP3.TRANSACTION_STATE TRANSACTION_STATE .
True if the reset attempt was successful, false if not. exception: IOException - If a network I/O error occurs in the process ofsending the reset command. |
retrieveMessage | public Reader retrieveMessage(int messageId) throws IOException(Code) | | Retrieve a message from the POP3 server. A retrieve message attempt
can only succeed if the client is in the
org.apache.commons.net.pop3.POP3.TRANSACTION_STATE TRANSACTION_STATE . Returns a DotTerminatedMessageReader instance
from which the entire message can be read.
Returns null if the retrieval attempt fails (e.g., if the specified
message number does not exist).
You must not issue any commands to the POP3 server (i.e., call any
other methods) until you finish reading the message from the
returned Reader instance.
The POP3 protocol uses the same stream for issuing commands as it does
for returning results. Therefore the returned Reader actually reads
directly from the POP3 connection. After the end of message has been
reached, new commands can be executed and their replies read. If
you do not follow these requirements, your program will not work
properly.
Parameters: messageId - The number of the message to fetch. A DotTerminatedMessageReader instancefrom which the entire message can be read.Returns null if the retrieval attempt fails (e.g., if the specifiedmessage number does not exist). exception: IOException - If a network I/O error occurs in the process ofsending the retrieve message command. |
retrieveMessageTop | public Reader retrieveMessageTop(int messageId, int numLines) throws IOException(Code) | | Retrieve only the specified top number of lines of a message from the
POP3 server. A retrieve top lines attempt
can only succeed if the client is in the
org.apache.commons.net.pop3.POP3.TRANSACTION_STATE TRANSACTION_STATE . Returns a DotTerminatedMessageReader instance
from which the specified top number of lines of the message can be
read.
Returns null if the retrieval attempt fails (e.g., if the specified
message number does not exist).
You must not issue any commands to the POP3 server (i.e., call any
other methods) until you finish reading the message from the returned
Reader instance.
The POP3 protocol uses the same stream for issuing commands as it does
for returning results. Therefore the returned Reader actually reads
directly from the POP3 connection. After the end of message has been
reached, new commands can be executed and their replies read. If
you do not follow these requirements, your program will not work
properly.
Parameters: messageId - The number of the message to fetch. Parameters: numLines - The top number of lines to fetch. This must be >= 0. A DotTerminatedMessageReader instancefrom which the specified top number of lines of the message can beread.Returns null if the retrieval attempt fails (e.g., if the specifiedmessage number does not exist). exception: IOException - If a network I/O error occurs in the process ofsending the top command. |
status | public POP3MessageInfo status() throws IOException(Code) | | Get the mailbox status. A status attempt can only
succeed if the client is in the
org.apache.commons.net.pop3.POP3.TRANSACTION_STATE TRANSACTION_STATE . Returns a POP3MessageInfo instance
containing the number of messages in the mailbox and the total
size of the messages in bytes. Returns null if the status the
attempt fails.
A POP3MessageInfo instance containing the number ofmessages in the mailbox and the total size of the messagesin bytes. Returns null if the status the attempt fails. exception: IOException - If a network I/O error occurs in the process ofsending the status command. |
|
|