code: public Session createSession(Properties properties, boolean debug) {
          Properties props = setup.configureJavaMailSessionProperties(properties, debug);
  
          if (log.isDebugEnabled()) {
              StringBuilder buf = new StringBuilder("Server Mail session properties are :");
              for (Map.Entry<Object, Object> entry : props.entrySet()) {
                  if (entry.getKey().toString().contains("imap")) {
                      buf.append("\n\t").append(entry.getKey()).append("\t : ").append(entry.getValue());
                  }
              }
              log.debug(buf.toString());
          }
  
          return Session.getInstance(props, null);
      }
docs: Creates a session configured for given server (IMAP, SMTP, ...).
  
  @param properties optional session properties, can be null.
  @param debug      if true enables JavaMail debug settings
  @return the session.