@Test public void testValidEmailSending() { String[] addresses = {"foo@example.com", "bar@abc.de", "bar@abc.de", "aslkd@ü."}; String[] cleaned = emailService.removeInvalidEmails(addresses); assertEquals(2, cleaned.length); assertTrue(Lists.newArrayList(cleaned).contains("foo@example.com")); assertTrue(Lists.newArrayList(cleaned).contains("bar@abc.de")); }
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()]); }
EmailServiceImpl implements EmailService { 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()]); } }
EmailServiceImpl implements EmailService { 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()]); } @Inject  EmailServiceImpl(final @Named(EMAIL_SERVICE_ENABLED) boolean enabled,
                            final @Named(EMAIL_SERVICE_HOST) String host,
                            final @Named(EMAIL_SERVICE_FROM) String from,
                            final @Named(EMAIL_SERVICE_SUBJECT_PREFIX) String subjectPrefix,
                            final @Named(EMAIL_SERVICE_USERNAME) String userName,
                            final @Named(EMAIL_SERVICE_PASSWORD) String password,
                            final @Named(EMAIL_SERVICE_AUTHENTICATION_ENABLED) boolean authenticationEnabled,
                            final @Named(EMAIL_SERVICE_SSL_ENABLED) boolean sslEnabled,
                            final EmailTextProcessor emailTextProcessor); }
EmailServiceImpl implements EmailService { 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()]); } @Inject  EmailServiceImpl(final @Named(EMAIL_SERVICE_ENABLED) boolean enabled,
                            final @Named(EMAIL_SERVICE_HOST) String host,
                            final @Named(EMAIL_SERVICE_FROM) String from,
                            final @Named(EMAIL_SERVICE_SUBJECT_PREFIX) String subjectPrefix,
                            final @Named(EMAIL_SERVICE_USERNAME) String userName,
                            final @Named(EMAIL_SERVICE_PASSWORD) String password,
                            final @Named(EMAIL_SERVICE_AUTHENTICATION_ENABLED) boolean authenticationEnabled,
                            final @Named(EMAIL_SERVICE_SSL_ENABLED) boolean sslEnabled,
                            final EmailTextProcessor emailTextProcessor); @Override boolean isActive(); @Override void setActive(boolean enabled); String getHost(); String getFrom(); String getSubjectPrefix(); @Override void doSend(String subject, String msg, String... to); @Override void sendEmailForUserPermission(Application.Name appName, UserInfo.Username user, EmailLinksList links); void setHost(String host); void setFrom(String from); void setSubjectPrefix(String subjectPrefix); }
EmailServiceImpl implements EmailService { 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()]); } @Inject  EmailServiceImpl(final @Named(EMAIL_SERVICE_ENABLED) boolean enabled,
                            final @Named(EMAIL_SERVICE_HOST) String host,
                            final @Named(EMAIL_SERVICE_FROM) String from,
                            final @Named(EMAIL_SERVICE_SUBJECT_PREFIX) String subjectPrefix,
                            final @Named(EMAIL_SERVICE_USERNAME) String userName,
                            final @Named(EMAIL_SERVICE_PASSWORD) String password,
                            final @Named(EMAIL_SERVICE_AUTHENTICATION_ENABLED) boolean authenticationEnabled,
                            final @Named(EMAIL_SERVICE_SSL_ENABLED) boolean sslEnabled,
                            final EmailTextProcessor emailTextProcessor); @Override boolean isActive(); @Override void setActive(boolean enabled); String getHost(); String getFrom(); String getSubjectPrefix(); @Override void doSend(String subject, String msg, String... to); @Override void sendEmailForUserPermission(Application.Name appName, UserInfo.Username user, EmailLinksList links); void setHost(String host); void setFrom(String from); void setSubjectPrefix(String subjectPrefix);  }