/** * Build a list of Strings from an email address list. Equivalent to iterating the list and * calling toString() on each element. * * @param emails * @return */ public static List<String> toStringList(List<EmailAddress> emails) { ArrayList<String> output = new ArrayList<String>(); if (emails != null && !emails.isEmpty()) { for (EmailAddress ea : emails) { output.add(ea.toString()); } } return output; }
/** * Build a list of Strings from an email address list. Equivalent to iterating the list and * calling toString() on each element. * * @param emails * @return */ public static List<String> toStringList(List<EmailAddress> emails) { ArrayList<String> output = new ArrayList<String>(); if (emails != null && !emails.isEmpty()) { for (EmailAddress ea : emails) { output.add(ea.toString()); } } return output; }
/** * Turn a list of email addresses into a comma delimited String. The output format of each * entry is: "First Last" <email@address.tld> * * @param emails * @return */ public static String toString(List<EmailAddress> emails) { StringBuilder output = new StringBuilder(); if (emails != null && !emails.isEmpty()) { for (EmailAddress ea : emails) { output.append(ea.toString()).append(", "); } // remove the extra trailing comma and space output.delete(output.length() - 2, output.length()); } return output.toString(); } }
/** * Turn a list of email addresses into a comma delimited String. The output format of each * entry is: "First Last" <email@address.tld> * * @param emails * @return */ public static String toString(List<EmailAddress> emails) { StringBuilder output = new StringBuilder(); if (emails != null && !emails.isEmpty()) { for (EmailAddress ea : emails) { output.append(ea.toString()).append(", "); } // remove the extra trailing comma and space output.delete(output.length() - 2, output.length()); } return output.toString(); } }
private void sendEmail(User user, SignupEmailNotification email) { logger.debug("sendMail called for user:" + user.getEid()); try { EmailMessage message = convertSignupEmail(email, user); if(message != null) { emailService.send(message); } } catch (NoRecipientsException e) { logger.error("Cannot send mail. No recipient." + e.getMessage()); } catch (AddressValidationException e) { //this should be caught when adding the email address, since it is validated then. logger.warn("Cannot send mail to user: " + user.getEid() + ". Invalid email address." + EmailAddress.toString(e.getInvalidEmailAddresses())); } }