/** * Overloaded method which takes typical email fields as arguments, to * prepare and populate the given new MimeMessage instance and send. Sender * of the email is loaded from omero.mail.from * * @param to * email address message is sent to * @param topic * topic of the message * @param body * body of the message * @param html * flag determines the content type to apply. * @param ccrecipients * list of email addresses message is sent as copy to * @param bccrecipients * list of email addresses message is sent as blind copy to */ public void sendEmail(final String to, final String topic, final String body, final boolean html, final List<String> ccrecipients, final List<String> bccrecipients) { this.sendEmail(sender, to, topic, body, html, ccrecipients, bccrecipients); }
private List<String> parseExtraRecipients() { Set<String> extraRecipients = new HashSet<String>(); for (final String e : extra) { if (mailUtil.validateEmail(e)) { extraRecipients.add(e); } else { rsp.invalidemails.add(e); } } return new ArrayList<String>(extraRecipients); }
@RolesAllowed("user") @Transactional(readOnly = false) public void notifyMembersOfShare(long shareId, String subject, String message, boolean html) { EventContext ec = getSecuritySystem().getEventContext(); Set<Experimenter> exps = getAllMembers(shareId); exps.add(getShare(shareId).getOwner()); Map<Experimenter, String> errors = new HashMap<Experimenter, String>(); for (final Experimenter e : exps) { if (e.getId() != ec.getCurrentUserId() && e.getEmail() != null && mailUtil.validateEmail(e.getEmail())) { try { mailUtil.sendEmail(e.getEmail(), subject, message, html, null, null); } catch (MailException me) { errors.put(e, me.getMessage()); } } } if (!errors.isEmpty()) { log.error(ServiceHandler.getResultsString(errors, null)); } }
"ApiUsageException", String.format("No recipients specified.")); this.sender = mailUtil.getSender(); if (StringUtils.isBlank(this.sender)) throw helper.cancel(new ERR(), null, "no-sender",
public void init(Helper helper) { this.helper = helper; this.sender = mailUtil.getSender(); if (omename == null) throw helper.cancel(new ERR(), null, "no-omename"); if (email == null) throw helper.cancel(new ERR(), null, "no-email"); helper.allowGuests(); this.helper.setSteps(1); }
public Object step(int step) throws Cancel { helper.assertStep(step); // early exist try { this.recipients.get(step); } catch (IndexOutOfBoundsException e) { return null; } String email = this.recipients.get(step); try { mailUtil.sendEmail(this.sender, email, subject, body, html, null, null); } catch (MailException me) { log.error(me.getMessage()); rsp.invalidemails.add(email); } rsp.success+=1; return null; }
if (e.getEmail() != null && mailUtil.validateEmail(e.getEmail())) { recipients.add(e.getEmail()); } else {
protected void sendBlind(Set<String> addresses, String subject, String body) { if (!isEnabled()) { // Printing warning since the enabled mail check should happen // as early as possible to prevent wasting resources. log.warn("sendBlind called when mail is disabled."); return; } if (addresses == null || addresses.isEmpty()) { log.debug("No emails found."); return; } for (String address : addresses) { try { // TODO: send in background thread getMailUtil().sendEmail(address, getSubjectPrefix() + subject, body, false /* not html */, null, null); } catch (Exception e) { log.error("Failed to send email: {} ", address, e); } } }
mailUtil.sendEmail(sender, e.getEmail(), subject, body, false, null, null); log.info("sent new password for {} to {}", e.getOmeName(), e.getEmail());