} catch (Exception e) {
email.addTo(recipient.toString());
}
}
} else {
throw new MailException("You must specify at least one recipient.");
}
List<Object> ccsList = (List<Object>) infos.get().get("ccs");
if (ccsList != null) {
for (Object cc : ccsList) {
email.addCc(cc.toString());
}
}
List<Object> bccsList = (List<Object>) infos.get().get("bccs");
if (bccsList != null) {
for (Object bcc : bccsList) {
try {
InternetAddress iAddress = new InternetAddress(bcc.toString());
email.addBcc(iAddress.getAddress(), iAddress.getPersonal());
} catch (Exception e) {
email.addBcc(bcc.toString());
}
}
}
if (!StringUtils.isEmpty(charset)) {
email.setCharset(charset);
}
email.setSubject(subject);
email.updateContentType(contentType);
if (headers != null) {
for (String key : headers.keySet()) {
email.addHeader(key, headers.get(key));
}
}
return Mail.send(email);
} catch (EmailException ex) {
throw new MailException("Cannot send email", ex);
}
}