class MailConnection {

  @VisibleForTesting
  static String findValidTarget( String folderName, final String fileName ) throws HopException {
    if ( fileName == null || folderName == null ) {
      throw new IllegalArgumentException( "Cannot have null arguments to findValidTarget" );
    }
    String fileNameRoot = FilenameUtils.getBaseName( fileName ), ext = "." + FilenameUtils.getExtension( fileName );
    if ( ( ext.length() == 1 ) ) { // only a "."
      ext = "";
    }
    String rtn = "", base = FilenameUtils.concat( folderName, fileNameRoot );
    int baseSz = base.length();
    StringBuilder build = new StringBuilder( baseSz ).append( base );
    int i = -1;
    do {
      i++;
      build.setLength( baseSz ); // bring string back to size
      build.append( i > 0 ? Integer.toString( i ) : "" ).append( ext );
      rtn = build.toString();
    } while ( HopVfs.fileExists( rtn ) );

    return rtn;
  }

  public  MailConnection( ILogChannel log, int protocol, String server, int port, String username,
                         String password, boolean usessl, boolean useproxy, String proxyusername );

}