Class POP3

java.lang.Object
org.apache.commons.net.SocketClient
org.apache.commons.net.pop3.POP3
Direct Known Subclasses:
POP3Client

public class POP3 extends SocketClient
The POP3 class is not meant to be used by itself and is provided only so that you may easily implement your own POP3 client if you so desire. If you have no need to perform your own implementation, you should use POP3Client.

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 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.

See Also:
  • Field Details Link icon

  • Constructor Details Link icon

    • POP3 Link icon

      public POP3()
      The default POP3Client constructor. Initializes the state to DISCONNECTED_STATE.
  • Method Details Link icon

    • _connectAction_ Link icon

      protected void _connectAction_() throws IOException
      Performs connection initialization and sets state to AUTHORIZATION_STATE.
      Overrides:
      _connectAction_ in class SocketClient
      Throws:
      IOException - (SocketException) if a problem occurs with the socket
    • disconnect Link icon

      public void disconnect() throws IOException
      Disconnects the client from the server, and sets the state to DISCONNECTED_STATE. The reply text information from the last issued command is voided to allow garbage collection of the memory used to store that information.
      Overrides:
      disconnect in class SocketClient
      Throws:
      IOException - If there is an error in disconnecting.
    • getAdditionalReply Link icon

      public void getAdditionalReply() throws IOException
      Retrieves the additional lines of a multi-line server reply.
      Throws:
      IOException - on error
    • getCommandSupport Link icon

      Provide command support to super-class
      Overrides:
      getCommandSupport in class SocketClient
      Returns:
      the CommandSupport instance, may be null
    • getReplyString Link icon

      Returns the reply to the last command sent to the server. The value is a single string containing all the reply lines including newlines. If the reply is a single line, but its format ndicates it should be a multiline reply, then you must call getAdditionalReply() to fetch the rest of the reply, and then call getReplyString again. You only have to worry about this if you are implementing your own client using the sendCommand methods.
      Returns:
      The last server response.
    • getReplyStrings Link icon

      public String[] getReplyStrings()
      Returns an array of lines received as a reply to the last command sent to the server. The lines have end of lines truncated. If the reply is a single line, but its format ndicates it should be a multiline reply, then you must call getAdditionalReply() to fetch the rest of the reply, and then call getReplyStrings again. You only have to worry about this if you are implementing your own client using the sendCommand methods.
      Returns:
      The last server response.
    • getState Link icon

      public int getState()
      Returns the current POP3 client state.
      Returns:
      The current POP3 client state.
    • removeProtocolCommandistener Link icon

      Removes a ProtocolCommandListener. Delegates this incorrectly named method - removeProtocolCommandistener (note the missing "L")- to the correct method SocketClient.removeProtocolCommandListener(org.apache.commons.net.ProtocolCommandListener)
      Parameters:
      listener - The ProtocolCommandListener to remove
    • sendCommand Link icon

      public int sendCommand(int command) throws IOException
      Sends a command with no arguments to the server and returns the reply code.
      Parameters:
      command - The POP3 command to send (one of the POP3Command constants).
      Returns:
      The server reply code (either POP3Reply.OK, POP3Reply.ERROR or POP3Reply.OK_INT).
      Throws:
      IOException - on error
    • sendCommand Link icon

      public int sendCommand(int command, String args) throws IOException
      Sends a command an arguments to the server and returns the reply code.
      Parameters:
      command - The POP3 command to send (one of the POP3Command constants).
      args - The command arguments.
      Returns:
      The server reply code (either POP3Reply.OK, POP3Reply.ERROR or POP3Reply.OK_INT).
      Throws:
      IOException - on error
    • sendCommand Link icon

      public int sendCommand(String command) throws IOException
      Sends a command with no arguments to the server and returns the reply code.
      Parameters:
      command - The POP3 command to send.
      Returns:
      The server reply code (either POP3Reply.OK, POP3Reply.ERROR or POP3Reply.OK_INT).
      Throws:
      IOException - on error
    • sendCommand Link icon

      public int sendCommand(String command, String args) throws IOException
      Sends a command an arguments to the server and returns the reply code.
      Parameters:
      command - The POP3 command to send.
      args - The command arguments.
      Returns:
      The server reply code (either POP3Reply.OK, POP3Reply.ERROR or POP3Reply.OK_INT).
      Throws:
      IOException - on error
    • setState Link icon

      public void setState(int state)
      Sets the internal POP3 state.
      Parameters:
      state - the new state. This must be one of the _STATE constants.