### Install IMAPNIO dependency Source: https://github.com/yahoo/imapnio/blob/master/README.md Add the IMAPNIO core dependency to your project's pom.xml file. ```xml com.yahoo.imapnio imapnio.core 5.0.15 ``` -------------------------------- ### Deploy to Nexus servers Source: https://github.com/yahoo/imapnio/blob/master/README.md Command for contributors to push artifacts to Nexus servers. ```bash $ mvn clean deploy -Dgpg.passphrase=[pathPhrase] ``` -------------------------------- ### Create an ImapAsyncClient instance Source: https://github.com/yahoo/imapnio/blob/master/README.md Initialize the client with a specified number of threads for handling server requests. ```java // Create a ImapAsyncClient instance with number of threads to handle the server requests final int numOfThreads = 5; final ImapAsyncClient imapClient = new ImapAsyncClient(numOfThreads); ``` -------------------------------- ### Establish an IMAP session Source: https://github.com/yahoo/imapnio/blob/master/README.md Connect to an IMAP server using a URI and configuration object, returning a future for the session creation. ```java // Create a new session via the ImapAsyncClient instance created above and connect to that server. For the illustration purpose, // "imaps://imap.server.com:993" is used final URI serverUri = new URI("imaps://imap.server.com:993"); final ImapAsyncSessionConfig config = new ImapAsyncSessionConfig(); config.setConnectionTimeoutMillis(5000); config.setReadTimeoutMillis(6000); final List sniNames = null; final InetSocketAddress localAddress = null; final Future future = imapClient.createSession(serverUri, config, localAddress, sniNames, DebugMode.DEBUG_OFF); //this version is a future-based nio client. Check whether future is done by following code. if (future.isDone()) { System.out.println("Future is done."); } ``` -------------------------------- ### Execute an IMAP command Source: https://github.com/yahoo/imapnio/blob/master/README.md Send a command to the IMAP server using the established session. ```java // Executes the capability command final Future capaCmdFuture = session.execute(new CapaCommand()); ``` -------------------------------- ### Handle IMAP server responses Source: https://github.com/yahoo/imapnio/blob/master/README.md Retrieve and map the response from the server once the command future is complete. ```java if (capaCmdFuture.isDone()) { System.out.println("Capability command is done."); final ImapAsyncResponse resp = capaCmdFuture.get(5, TimeUnit.MILLISECONDS); final ImapResponseMapper mapper = new ImapResponseMapper(); final Capability capa = mapper.readValue(resp.getResponseLines().toArray(new IMAPResponse[0]), Capability.class); final List values = capa.getCapability("AUTH"); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.