String[] removeInvalidEmails(String[] emails){
  Set<String> cleanAddresses=new HashSet<>();
  for (  String emailTo : emails) {
    if (emailVal.isValid(emailTo)) {
      cleanAddresses.add(emailTo);
    }
 else {
      LOGGER.warn("Remove email address: [" + emailTo + "] from email recipients, because it is not valid");
    }
  }
  return cleanAddresses.toArray(new String[cleanAddresses.size()]);
}

String [ ] removeInvalidEmails ( String [ ] emails ) { Set < String > cleanAddresses = new HashSet < > ( ) ; for ( String emailTo : emails ) { if ( emailVal . isValid ( emailTo ) ) { cleanAddresses . add ( emailTo ) ; } else { LOGGER . warn ( "Remove email address: [" + emailTo + "] from email recipients, because it is not valid" ) ; } } return cleanAddresses . toArray ( new String [ cleanAddresses . size ( ) ] ) ; }
removed duplicated and wrong addresses from the given set .
