code: @Override
    public synchronized boolean connect(final DisconnectListener listener) {
      reset();
  
      ChannelFuture future = bootstrap.connect(new InetSocketAddress(config.getHost(),
          config.getPort()));
  
      Channel channel = future.awaitUninterruptibly().getChannel();
      if (!future.isSuccess()) {
        throw new RuntimeException("Could not connect channel", future.getCause());
      }
  
      this.channel = channel;
      this.disconnectListener = listener;
      if (null != listener) {
        // https://issues.jboss.org/browse/NETTY-47?page=com.atlassian.jirafisheyeplugin%3Afisheye-issuepanel#issue-tabs
        channel.getCloseFuture().addListener(new ChannelFutureListener() {
          @Override
          public void operationComplete(ChannelFuture future) throws Exception {
            mailClientHandler.idleAcknowledged.set(false);
            mailClientHandler.disconnected();
            listener.disconnected();
          }
        });
      }
      return login();
    }
docs: Connects to the IMAP server logs in with the given credentials.