com.jscape.inet.imap

## Class Imap

- java.lang.Object
- - com.jscape.inet.imap.Imap

- All Implemented Interfaces:
    java.io.Serializable, java.lang.AutoCloseable
  Direct Known Subclasses:
    ImapSsh, ImapSsl

      public class Imap
      extends java.lang.Object
      implements java.lang.AutoCloseable, java.io.Serializable

  Implements the basic functionality of a IMAP client.

  Example Usage:

       // new instance with hostname, username and password
       Imap imap = new Imap("imap4.myserver.com","jsmith","secret");
       try {
         // connect to IMAP4 server
         imap.connect();

         // get messages
         int messageCount = imap.getMessageCount();
         for(int i = 1; i <= messageCount(); ++i) {
           EmailMessage em = imap.getMessage(i);
         }

         // disconnect
         imap.disconnect();
       }
       catch(Exception e) {
         System.out.println(e);
       }

  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Imap.Authentication`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `AUTH_CRAM_MD5` CRAM_MD5 authentication.
    `static int` | `AUTH_LOGIN` Standard username/password authentication.
    `static int` | `AUTH_XOAUTH2`
    `static int` | `FLAG_ANSWERED` Flag used in marking a message as Answered.
    `static int` | `FLAG_DELETED` Flag used in marking a message as Deleted.
    `static int` | `FLAG_DRAFT` Flag used in marking a message as Draft.
    `static int` | `FLAG_FLAGGED` Flag used in marking a message as Flagged.
    `static int` | `FLAG_MODE_ADD` Flag mode used to add flags.
    `static int` | `FLAG_MODE_DELETE` Flag mode used to delete flags.
    `static int` | `FLAG_MODE_REPLACE` Flag mode used to replace flags.
    `static int` | `FLAG_RECENT` Flag used in marking a message as Recent.
    `static int` | `FLAG_SEEN` Flag used in marking a message as Seen.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Imap()` Constructs a new Imap instance.
    `Imap(java.lang.String hostname, java.lang.String username, java.lang.String password)` Constructs a new Imap instance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addImapListener(ImapListener listener)` Adds Imap event listener.
    `void` | `append(java.lang.String mailbox, EmailMessage message)` Appends an email message to the specified mailbox.
    `void` | `append(java.lang.String mailbox, java.util.Enumeration messages)` Appends an email message to the specified mailbox.
    `void` | `clearProxySettings()` Clears proxy server values.
    `void` | `close()`
    `Imap` | `connect()` Connects to an IMAP server.
    `void` | `createMailbox(java.lang.String mailbox)` Creates a new mailbox on IMAP server.
    `void` | `deleteMailbox(java.lang.String mailbox)` Deletes mailbox on IMAP server.
    `void` | `deleteMessage(int index)` Removes a message from the current mailbox.
    `void` | `deleteMessages(int startIndex, int endIndex)` Removes range of messages from the current mailbox.
    `void` | `disconnect()` Closes the IMAP session.
    `void` | `expunge()` Deletes messages marked for deletion from current mailbox.
    `int` | `getAuthMode()` Gets the authentication mode used when logging into IMAP4 server.
    `int` | `getConnectTimeout()` Gets the timeout used when opening a connection.
    `java.io.PrintStream` | `getDebugStream()` Gets PrintStream used in reporting debug statements.
    `java.lang.String` | `getHostname()` Gets the name of the remote host.
    `java.util.Enumeration` | `getMailboxes()` Deprecated. this method uses the FIND ALL.MAILBOXES command as identifed in RFC 1730 and has been obsoleted by RFC 2060, it is recommended you use the listMailboxes command instead.
    `EmailMessage` | `getMessage(int index)` Retrieves a message from the current mailbox.
    `int` | `getMessageCount()` Gets the number of messages in the current mailbox.
    `MimeHeader` | `getMessageHeader(int index, java.lang.String name)` Gets named header for a message.
    `java.util.Enumeration` | `getMessageHeaders(int index)` Gets message headers for a message.
    `int[]` | `getMessageID(java.lang.String expression)` Gets messages matching specified SEARCH expression.
    `java.util.Enumeration` | `getMessages()` Gets all available messages in current mailbox from IMAP server.
    `java.util.Enumeration` | `getMessages(int[] ids)` Gets messages for specified message ID's.
    `java.util.Enumeration` | `getMessages(java.lang.String expression)` Gets messages matching specified SEARCH expression.
    `java.util.Enumeration` | `getMessagesWithFlags()` Gets all available messages with flags in current mailbox from IMAP server.
    `java.util.Enumeration` | `getMessagesWithFlags(int[] ids)` Gets messages for specified message ID's with flags.
    `java.util.Enumeration` | `getMessagesWithFlags(java.lang.String expression)` Gets messages with flags matching specified SEARCH expression.
    `ImapMessage` | `getMessageWithFlags(int index)` Gets message from current mailbox along with message flags.
    `int[]` | `getNewMessageID()` Gets an int[] representing the ID(s) of new messages in current mailbox from IMAP server.
    `java.util.Enumeration` | `getNewMessages()` Gets all new messages in current mailbox from IMAP server.
    `java.util.Enumeration` | `getNewMessagesWithFlags()` Gets all new messages in current mailbox with message flags.
    `int` | `getPort()` Gets port of IMAP server.
    `int` | `getReadTimeout()` Gets the timeout used when reading responses from server.
    `int` | `getTimeout()` Deprecated. Replaced by getConnectTimeout and getReadTimeout
    `int` | `getUid(int msgId)` Gets unique message id for a message on IMAP server.
    `int[]` | `getUid(int startMsgId, int endMsgId)` Gets unique message id's for a range of messages on IMAP server.
    `java.lang.String` | `getUsername()` Gets the username to be sent to the remote host.
    `boolean` | `isConnected()` True, if there is a connection to the IMAP server.
    `boolean` | `isDebug()` Gets debug level of IMAP session.
    `boolean` | `isDelete()` Checks whether to delete messages automatically after retrieval.
    `java.lang.String` | `issueCommand(java.lang.String command)` This method sends out a request and waits for a response.
    `java.util.Enumeration` | `listMailboxes()` Gets all mailboxes for account.
    `java.util.Enumeration` | `listMailboxes(java.lang.String mailbox, java.lang.String filter)` Gets all mailboxes for account.
    `void` | `removeImapListener(ImapListener listener)` Removes specified IMAP event listener.
    `void` | `renameMailbox(java.lang.String mailbox, java.lang.String newMailbox)` Renames mailbox on IMAP server.
    `void` | `selectMailbox(java.lang.String mailbox)` Selects mailbox on IMAP server.
    `Imap` | `setAuthentication(Imap.Authentication authentication)`
    `void` | `setAuthMode(int mode)` Sets the authentication mode used when logging into IMAP4 server.
    `void` | `setConnectTimeout(int timeout)` Sets the timeout for opening the 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 automatically mark messages for deletion after retrieval.
    `void` | `setHostname(java.lang.String hostname)` Sets the name of the remote host to cennect to.
    `void` | `setPassword(java.lang.String password)` Sets the password to be sent to the remote host.
    `void` | `setPort(int port)` Sets port of IMAP 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 server.
    `void` | `setTimeout(int timeout)` Deprecated. Replaced by setConnectTimeout and setReadTimeout
    `void` | `setUsername(java.lang.String username)` Sets the username to be sent to the remote host.
    `void` | `store(int message, int mode, int flag)` Sets message flags for a single message in an IMAP mailbox.
    `void` | `store(int startMessage, int endMessage, int mode, int flag)` Sets message flags for a range of messages in an IMAP mailbox.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### AUTH_LOGIN

          public static final int AUTH_LOGIN

      Standard username/password authentication. Use with `setAuthMode` method.
      See Also:
        Constant Field Values

    - #### AUTH_CRAM_MD5

          public static final int AUTH_CRAM_MD5

      CRAM_MD5 authentication. Use with `setAuthMode` method.
      See Also:
        Constant Field Values

    - #### AUTH_XOAUTH2

          public static final int AUTH_XOAUTH2

      See Also:
        Constant Field Values

    - #### FLAG_MODE_REPLACE

          public static final int FLAG_MODE_REPLACE

      Flag mode used to replace flags.
      See Also:
        Constant Field Values

    - #### FLAG_MODE_ADD

          public static final int FLAG_MODE_ADD

      Flag mode used to add flags.
      See Also:
        Constant Field Values

    - #### FLAG_MODE_DELETE

          public static final int FLAG_MODE_DELETE

      Flag mode used to delete flags.
      See Also:
        Constant Field Values

    - #### FLAG_SEEN

          public static final int FLAG_SEEN

      Flag used in marking a message as Seen.
      See Also:
        Constant Field Values

    - #### FLAG_ANSWERED

          public static final int FLAG_ANSWERED

      Flag used in marking a message as Answered.
      See Also:
        Constant Field Values

    - #### FLAG_FLAGGED

          public static final int FLAG_FLAGGED

      Flag used in marking a message as Flagged.
      See Also:
        Constant Field Values

    - #### FLAG_DELETED

          public static final int FLAG_DELETED

      Flag used in marking a message as Deleted.
      See Also:
        Constant Field Values

    - #### FLAG_DRAFT

          public static final int FLAG_DRAFT

      Flag used in marking a message as Draft.
      See Also:
        Constant Field Values

    - #### FLAG_RECENT

          public static final int FLAG_RECENT

      Flag used in marking a message as Recent.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Imap

          public Imap()

      Constructs a new Imap instance.

    - #### Imap

          public Imap(java.lang.String hostname,
                      java.lang.String username,
                      java.lang.String password)

      Constructs a new Imap instance. Sets hostname, username and password for IMAP connection.
      Parameters:
        `hostname` - the hostname of IMAP server
        `username` - the username of IMAP user
        `password` - the password of IMAP user

  - ### Method Detail

    - #### setAuthentication

          public Imap setAuthentication(Imap.Authentication authentication)

    - #### setAuthMode

          public void setAuthMode(int mode)

      Sets the authentication mode used when logging into IMAP4 server. Possible values are Imap.AUTH_LOGIN for username/password authentication or Imap.AUTH_CRAM_MD5 for CRAM-MD5 authentication.
      Parameters:
        `mode` - authentication mode

    - #### getAuthMode

          public int getAuthMode()

      Gets the authentication mode used when logging into IMAP4 server. Possible values are Imap.AUTH_LOGIN for username/password authentication or Imap.AUTH_CRAM_MD5 for CRAM-MD5 authentication.
      Returns:
        authentication mode

    - #### setConnectTimeout

          public void setConnectTimeout(int timeout)

      Sets the timeout for opening the connection.

      Default is 30 seconds.
      Parameters:
        `timeout` - the timeout in milliseconds

    - #### getConnectTimeout

          public int getConnectTimeout()

      Gets the timeout used when opening a connection.

      Default is 30 seconds.
      Returns:
        timeout server connection.

    - #### isConnected

          public boolean isConnected()

      True, if there is a connection to the IMAP server.
      Returns:
        state of the connection
      See Also:
        `connect()`, `disconnect()`

    - #### setDebug

          public void setDebug(boolean debug)

      Sets debugging state. All debug statements are reported to debug stream. Default debug stream is System.out
      Parameters:
        `debug` - `true` to turn debugging on
      See Also:
        `setDebugStream(java.io.PrintStream)`

    - #### isDebug

          public boolean isDebug()

      Gets debug level of IMAP session. Debug messages are sent to debug stream. Default debug stream is System.out
      Returns:
        `true` if debugging is on
      See Also:
        `setDebugStream(java.io.PrintStream)`

    - #### setDebugStream

          public void setDebugStream(java.io.PrintStream debugStream)

      Sets PrintStream used in reporting debug statements. Default PrintStream is System.out
      Parameters:
        `debugStream` - the PrintStream to send debug statements to
      See Also:
        `PrintStream`

    - #### getDebugStream

          public java.io.PrintStream getDebugStream()

      Gets PrintStream used in reporting debug statements. Default PrintStream is System.out
      Returns:
        the debug stream
      See Also:
        `PrintStream`

    - #### setDelete

          public void setDelete(boolean delete)

      Defines whether to automatically mark messages for deletion after retrieval. Messages will NOT be deleted until expunge method is invoked. Default is `false`.
      Parameters:
        `delete` - `true` to delete automatically
      See Also:
        `expunge()`

    - #### isDelete

          public boolean isDelete()

      Checks whether to delete messages automatically after retrieval. Default is `false`.
      Returns:
        `true` if should delete automatically

    - #### setHostname

          public void setHostname(java.lang.String hostname)

      Sets the name of the remote host to cennect to.
      Parameters:
        `hostname` - the hostname of IMAP server

    - #### getHostname

          public java.lang.String getHostname()

      Gets the name of the remote host.
      Returns:
        `remoteHost` to connect to.

    - #### getMailboxes

          public java.util.Enumeration getMailboxes()
                                             throws ImapException

      Deprecated. this method uses the FIND ALL.MAILBOXES command as identifed in RFC 1730 and has been obsoleted by RFC 2060, it is recommended you use the listMailboxes command instead.
      Gets all mailboxes found for account.
      Returns:
        an Enumeration of String with each element representing a mailbox name
      Throws:
        `ImapException` - if an I/O or IMAP related error occurs
      See Also:
        `listMailboxes()`

    - #### listMailboxes

          public java.util.Enumeration listMailboxes()
                                              throws ImapException

      Gets all mailboxes for account.
      Returns:
        an Enumeration of String with each element representing a mailbox name
      Throws:
        `ImapException` - if an I/O or IMAP related error occurs

    - #### listMailboxes

          public java.util.Enumeration listMailboxes(java.lang.String mailbox,
                                                     java.lang.String filter)
                                              throws ImapException

      Gets all mailboxes for account.
      Parameters:
        `mailbox` - the root mailbox to search under or null to return all mailboxes
        `filter` - the filter to use or null to return all mailboxes
      Returns:
        an Enumeration of String with each element representing a mailbox name
      Throws:
        `ImapException` - if an I/O or IMAP related error occurs

    - #### getMessage

          public EmailMessage getMessage(int index)
                                  throws ImapException

      Retrieves a message from the current mailbox. The method retrieves the message with the given index from the IMAP server. Message numbering is one based, meaning that message numbers range is from 1 to `getMessageCount()`.
      Parameters:
        `index` - the index of the message to retrieve
      Returns:
        an `EmailMessage`
      Throws:
        `ImapException` - if an I/O or IMAP related error occurs
      See Also:
        `getMessageCount()`, `EmailMessage`

    - #### getMessageCount

          public int getMessageCount()
                              throws ImapException

      Gets the number of messages in the current mailbox.
      Returns:
        the number of message in currently selected mailbox
      Throws:
        `ImapException` - if an I/O or IMAP related error occurs

    - #### getMessageHeader

          public MimeHeader getMessageHeader(int index,
                                             java.lang.String name)
                                      throws ImapException

      Gets named header for a message.
      Parameters:
        `index` - the index of the message to retrieve
        `name` - the name of the header to retrieve
      Returns:
        a MimeHeader
      Throws:
        `ImapException` - If a Imap error occurs.
      See Also:
        `MimeHeader`

    - #### getMessageHeaders

          public java.util.Enumeration getMessageHeaders(int index)
                                                  throws ImapException

      Gets message headers for a message.
      Parameters:
        `index` - the index of message to retrieve
      Returns:
        an Enumeration of MimeHeader
      Throws:
        `ImapException` - if an I/O or IMAP related error occurs
      See Also:
        `Enumeration`, `MimeHeader`

    - #### getMessageID

          public int[] getMessageID(java.lang.String expression)
                             throws ImapException

      Gets messages matching specified SEARCH expression.
      Parameters:
        `expression` - a valid SEARCH key
      Returns:
        an int[] of message ID's matching expression
      Throws:
        `ImapException` - if an I/O or IMAP related error occurs

    - #### getMessageWithFlags

          public ImapMessage getMessageWithFlags(int index)
                                          throws ImapException

      Gets message from current mailbox along with message flags. Message number is one based, meaning that message numbers range from 1 to `getMessageCount()`
      Parameters:
        `index` - Message index
      Returns:
        an ImapMessage
      Throws:
        `ImapException` - if an I/O or IMAP related error occurs
      See Also:
        `getMessageCount()`, `ImapMessage`

    - #### getMessages

          public java.util.Enumeration getMessages(int[] ids)
                                            throws ImapException

      Gets messages for specified message ID's.
      Parameters:
        `ids` - the message ID's to retrieve
      Returns:
        an Enumeration of EmailMessage
      Throws:
        `ImapException` - if an I/O or IMAP related error occurs
      See Also:
        `EmailMessage`

    - #### getMessages

          public java.util.Enumeration getMessages(java.lang.String expression)
                                            throws ImapException

      Gets messages matching specified SEARCH expression.
      Parameters:
        `expression` - a valid SEARCH key
      Returns:
        an Enumeration of EmailMessage
      Throws:
        `ImapException` - if an I/O or IMAP related error occurs
      See Also:
        `EmailMessage`

    - #### getMessages

          public java.util.Enumeration getMessages()
                                            throws ImapException

      Gets all available messages in current mailbox from IMAP server. All messages are stored in memory resulting in potential memory issues if not enough memory is available. To avoid potential memory issue you may retrieve messages individually using the `getMessage(int index)` method.
      Returns:
        an Enumeration of `EmailMessage`
      Throws:
        `ImapException` - if I/O or IMAP related error occurs
      See Also:
        `EmailMessage`

    - #### getMessagesWithFlags

          public java.util.Enumeration getMessagesWithFlags(int[] ids)
                                                     throws ImapException

      Gets messages for specified message ID's with flags.
      Parameters:
        `ids` - the message ID's to retrieve
      Returns:
        an Enumeration of ImapMessage
      Throws:
        `ImapException` - if an I/O or IMAP related error occurs
      See Also:
        `ImapMessage`

    - #### getMessagesWithFlags

          public java.util.Enumeration getMessagesWithFlags(java.lang.String expression)
                                                     throws ImapException

      Gets messages with flags matching specified SEARCH expression.
      Parameters:
        `expression` - a valid SEARCH key
      Returns:
        an Enumeration of ImapMessage
      Throws:
        `ImapException` - if an I/O or IMAP related error occurs
      See Also:
        `ImapMessage`

    - #### getMessagesWithFlags

          public java.util.Enumeration getMessagesWithFlags()
                                                     throws ImapException

      Gets all available messages with flags in current mailbox from IMAP server. All messages are stored in memory resulting in potential memory issues if not enough memory is available. To avoid potential memory issue you may retrieve messages individually using the `getMessageWithFlags(int index)` method.
      Returns:
        an Enumeration of `ImapMessage`
      Throws:
        `ImapException` - if an I/O or IMAP related error occurs
      See Also:
        `ImapMessage`

    - #### getNewMessageID

          public int[] getNewMessageID()
                                throws ImapException

      Gets an int[] representing the ID(s) of new messages in current mailbox from IMAP server. Each ID in int[] represents the corresponding new message id on server. You can then retrieve the new message using the getMessage method passing the message ID as an argument. To get all new messages automatically use the getNewMessages method.
      Returns:
        an int[] of all new message ID(s) or null if no new messages are found
      Throws:
        `ImapException` - if I/O or IMAP related error occurs
      See Also:
        `getMessage(int)`, `getNewMessages()`

    - #### getNewMessages

          public java.util.Enumeration getNewMessages()
                                               throws ImapException

      Gets all new messages in current mailbox from IMAP server. Upon retrieving new messages the messages are flagged as "read" and are no longer considered new. To get the ID(s) of the new messages without retrieving the actual message content use the getNewMessageID method.
      Returns:
        an Enumeration of EmailMessage
      Throws:
        `ImapException` - if I/O or IMAP related error occurs
      See Also:
        `EmailMessage`, `getNewMessageID()`

    - #### getNewMessagesWithFlags

          public java.util.Enumeration getNewMessagesWithFlags()
                                                        throws ImapException

      Gets all new messages in current mailbox with message flags.
      Returns:
        an Enumeration of ImapMessage
      Throws:
        `ImapException` - if an I/O or IMAP related error occurs
      See Also:
        `ImapMessage`

    - #### setPassword

          public void setPassword(java.lang.String password)

      Sets the password to be sent to the remote host.
      Parameters:
        `password` - to be sent to the remote host.

    - #### setPort

          public void setPort(int port)

      Sets port of IMAP server. Default port value is 143.
      Parameters:
        `port` - the port of IMAP server

    - #### getPort

          public int getPort()

      Gets port of IMAP server. Default port value is 143.
      Returns:
        port

    - #### setReadTimeout

          public void setReadTimeout(int timeout)

      Sets the timeout for reading responses from server. Default is 30 seconds.
      Parameters:
        `timeout` - the timeout in milliseconds

    - #### getReadTimeout

          public int getReadTimeout()

      Gets the timeout used when reading responses from server. Default is 30 seconds.
      Returns:
        reading from server timeout.

    - #### setTimeout

          public void setTimeout(int timeout)

      Deprecated. Replaced by setConnectTimeout and setReadTimeout
      Sets the timeout for opening connection to server. Default is 30 seconds.
      Parameters:
        `timeout` - the timeout in milliseconds
      See Also:
        `setConnectTimeout(int)`, `setReadTimeout(int)`

    - #### getTimeout

          public int getTimeout()

      Deprecated. Replaced by getConnectTimeout and getReadTimeout
      Gets the timeout for opening connection to server. Default is 30 seconds.
      Returns:
        timeout in milliseconds
      See Also:
        `getConnectTimeout()`, `getReadTimeout()`

    - #### getUid

          public int getUid(int msgId)
                     throws ImapException

      Gets unique message id for a message on IMAP server.
      Parameters:
        `msgId` - 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.
      Returns:
        a unique message id
      Throws:
        `ImapException` - if an I/O or IMAP related error occurs

    - #### getUid

          public int[] getUid(int startMsgId,
                              int endMsgId)
                       throws ImapException

      Gets unique message id's for a range of messages on IMAP server.
      Parameters:
        `startMsgId` - the starting 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.
        `endMsgId` - the ending message number to get the unique message id for
      Returns:
        a int[] of unique message id's
      Throws:
        `ImapException` - if an I/O or IMAP related error occurs

    - #### setUsername

          public void setUsername(java.lang.String username)

      Sets the username to be sent to the remote host.
      Parameters:
        `username` - to be sent to the remote host.

    - #### getUsername

          public java.lang.String getUsername()

      Gets the username to be sent to the remote host.
      Returns:
        `username` to be sent.

    - #### addImapListener

          public void addImapListener(ImapListener listener)

      Adds Imap event listener.
      Parameters:
        `listener` - the listener to add
      See Also:
        `ImapListener`

    - #### setProxyAuthentication

          public void setProxyAuthentication(java.lang.String proxyUsername,
                                             java.lang.String proxyPassword)

      Sets the username and password to use when for authentication with proxy server. To clear these settings invoke the `#clearProxySettings` method.
      Parameters:
        `proxyUsername` - the proxy username
        `proxyPassword` - the proxy password
      See Also:
        `clearProxySettings()`

    - #### setProxyHost

          public void setProxyHost(java.lang.String proxyHostname,
                                   int proxyPort)

      Sets the proxy hostname and port for this connection. To clear these settings invoke the `#clearProxySettings` method.
      Parameters:
        `proxyHostname` - the hostname or ip address of the proxy server
        `proxyPort` - the port of the proxy server
      See Also:
        `clearProxySettings()`

    - #### setProxyType

          public void setProxyType(java.lang.String proxyType)

      Sets the proxy type will be used for this connection.
      Parameters:
        `proxyType` - The proxy type. Valid values: HTTP, SOCKS5

    - #### clearProxySettings

          public void clearProxySettings()

      Clears proxy server values.

    - #### append

          public void append(java.lang.String mailbox,
                             java.util.Enumeration messages)
                      throws ImapException

      Appends an email message to the specified mailbox.
      Parameters:
        `mailbox` - the mailbox to append to
        `messages` - the email message to append
      Throws:
        `ImapException` - if an I/O or IMAP related error occurs

    - #### append

          public void append(java.lang.String mailbox,
                             EmailMessage message)
                      throws ImapException

      Appends an email message to the specified mailbox.
      Parameters:
        `mailbox` - the mailbox to append to
        `message` - the email message to append
      Throws:
        `ImapException` - if an I/O or IMAP related error occurs

    - #### connect

          public Imap connect()
                       throws ImapException

      Connects to an IMAP server.

      Throws:
        `ImapException` - if an I/O or IMAP related error occurs

    - #### createMailbox

          public void createMailbox(java.lang.String mailbox)
                             throws ImapException

      Creates a new mailbox on IMAP server.
      Parameters:
        `mailbox` - the name of the mailbox
      Throws:
        `ImapException` - if an I/O or IMAP related error occurs

    - #### deleteMailbox

          public void deleteMailbox(java.lang.String mailbox)
                             throws ImapException

      Deletes mailbox on IMAP server.
      Parameters:
        `mailbox` - the name of the mailbox to delete
      Throws:
        `ImapException` - if an I/O or IMAP related error occurs

    - #### deleteMessage

          public void deleteMessage(int index)
                             throws ImapException

      Removes a message from the current mailbox. The method marks the message with the given index in the current mailbox for deletion. To process messages marked for deletion invoke the expunge() method. Message numbering is one based, meaning that message numbers range is from 1 to `getMessageCount()`.
      Parameters:
        `index` - the index of message to mark for deletion
      Throws:
        `ImapException` - if an I/O or IMAP related error occurs
      See Also:
        `getMessageCount()`, `expunge()`

    - #### deleteMessages

          public void deleteMessages(int startIndex,
                                     int endIndex)
                              throws ImapException

      Removes range of messages from the current mailbox. The method marks the messages within the given start index and end index in the current mailbox for deletion. To process messages marked for deletion invoke the expunge() method. Message numbering is one based, meaning that message numbers range is from 1 to `getMessageCount()`.
      Parameters:
        `startIndex` - the start index of message range to mark for deletion
        `endIndex` - the end index of message range to mark for deletion
      Throws:
        `ImapException` - if an I/O or IMAP related error occurs
      See Also:
        `getMessageCount()`, `expunge()`

    - #### disconnect

          public void disconnect()
                          throws ImapException

      Closes the IMAP session.
      Throws:
        `ImapException` - if an I/O or IMAP related error occurs
      See Also:
        `connect()`

    - #### close

          public void close()
                     throws java.lang.Exception

      Specified by:
        `close` in interface `java.lang.AutoCloseable`
      Throws:
        `java.lang.Exception`

    - #### expunge

          public void expunge()
                       throws ImapException

      Deletes messages marked for deletion from current mailbox.
      Throws:
        `ImapException` - if an I/O or IMAP related error occurs
      See Also:
        `deleteMessage(int)`, `setDelete(boolean)`

    - #### issueCommand

          public java.lang.String issueCommand(java.lang.String command)
                                        throws ImapException

      This method sends out a request and waits for a response. The response with a "-" sign in place of the first character denotes IMAP protocol error, and an `ImapException` is thrown to signal it.
      Parameters:
        `command` - to send to server
      Returns:
        string containing an answer message from the server. If NO, or BAD are received, an ImapException is raised to signal that command didn't have completed successfuly.
      Throws:
        `ImapException` - if an IMAP related error occurs

    - #### removeImapListener

          public void removeImapListener(ImapListener listener)

      Removes specified IMAP event listener.
      Parameters:
        `listener` - the listener to remove
      See Also:
        `ImapListener`

    - #### renameMailbox

          public void renameMailbox(java.lang.String mailbox,
                                    java.lang.String newMailbox)
                             throws ImapException

      Renames mailbox on IMAP server.
      Parameters:
        `mailbox` - the name of mailbox to be renamed
        `newMailbox` - the new name of mailbox
      Throws:
        `ImapException` - if an I/O or IMAP related error occurs

    - #### selectMailbox

          public void selectMailbox(java.lang.String mailbox)
                             throws ImapException

      Selects mailbox on IMAP server.
      Parameters:
        `mailbox` - the name of the mailbox to select
      Throws:
        `ImapException` - if an I/O or IMAP related error occurs

    - #### store

          public void store(int message,
                            int mode,
                            int flag)
                     throws ImapException

      Sets message flags for a single message in an IMAP mailbox.
      Parameters:
        `message` - the message id
        `mode` - the flag mode
        `flag` - the flag
      Throws:
        `ImapException` - if an I/O or IMAP related error occurs
      See Also:
        `FLAG_MODE_REPLACE`, `FLAG_MODE_ADD`, `FLAG_MODE_DELETE`, `FLAG_SEEN`, `FLAG_ANSWERED`, `FLAG_FLAGGED`, `FLAG_DELETED`, `FLAG_DRAFT`, `FLAG_RECENT`

    - #### store

          public void store(int startMessage,
                            int endMessage,
                            int mode,
                            int flag)
                     throws ImapException

      Sets message flags for a range of messages in an IMAP mailbox.
      Parameters:
        `startMessage` - the start message id
        `endMessage` - the end message id
        `mode` - the flag mode
        `flag` - the flag
      Throws:
        `ImapException` - if an I/O or IMAP related error occurs
      See Also:
        `FLAG_MODE_REPLACE`, `FLAG_MODE_ADD`, `FLAG_MODE_DELETE`, `FLAG_SEEN`, `FLAG_ANSWERED`, `FLAG_FLAGGED`, `FLAG_DELETED`, `FLAG_DRAFT`, `FLAG_RECENT`

Copyright © JSCAPE LLC. 1999-2021. All Rights Reserved