List of usage examples for org.springframework.mail SimpleMailMessage setTo
@Override public void setTo(String... to)
From source file:edu.wisc.my.portlets.feedback.dao.SimpleFeedbackMessageFormatterImpl.java
public SimpleMailMessage format(Feedback feedback) { SimpleMailMessage message = new SimpleMailMessage(); message.setTo(targetEmail); message.setFrom(fromAddress);//w w w.j a v a 2s .c o m message.setSubject("[Feedback] " + feedback.getSubject()); StringBuffer details = new StringBuffer(); details.append("NAME: "); details.append(null == feedback.getName() ? "<empty>" : feedback.getName()); details.append("\n"); details.append("\n"); details.append("NETID: "); details.append(null == feedback.getNetid() ? "<empty>" : feedback.getNetid()); details.append("\n"); details.append("\n"); details.append("EMAIL: "); details.append(null == feedback.getEmailAddress() ? "<empty>" : feedback.getEmailAddress()); details.append("\n"); details.append("\n"); details.append("PHONE: "); details.append(null == feedback.getPhoneNumber() ? "<empty>" : feedback.getPhoneNumber()); details.append("\n"); details.append("\n"); details.append("DETAILS: "); details.append(feedback.getDetails()); message.setText(details.toString()); return message; }
From source file:org.darwinathome.server.email.EmailSender.java
public void sendEmail(String toEmail, String fromEmail, String subject, Map<String, Object> model) throws IOException, TemplateException { SimpleMailMessage message = new SimpleMailMessage(); message.setSubject(subject);//from w ww .j ava2 s. co m message.setFrom(fromEmail); message.setTo(toEmail); String emailText = createEmailText(model); message.setText(emailText); mailSender.send(message); }
From source file:uk.org.funcube.fcdw.config.MailConfig.java
@Bean SimpleMailMessage alertMailMessage() {/*from ww w . j a v a 2 s . co m*/ SimpleMailMessage alertMailMessage = new SimpleMailMessage(); alertMailMessage.setFrom("dave@g4dpz.me.uk"); alertMailMessage.setTo("dave@g4dpz.me.uk"); alertMailMessage.setSubject("Alert - Exception occurred. Please investigate"); return alertMailMessage; }
From source file:com.badgersoft.eseoprocessor.config.MailConfig.java
@Bean SimpleMailMessage alertMailMessage() {//from w ww .ja v a 2s.co m SimpleMailMessage alertMailMessage = new SimpleMailMessage(); alertMailMessage.setFrom("dave@g4dpz.me.uk"); alertMailMessage.setTo("operations@funcube.org.uk"); alertMailMessage.setSubject("Alert - Exception occurred. Please investigate"); return alertMailMessage; }
From source file:csns.util.NotificationService.java
public void notifiy(Subscribable subscribable, String subject, String vTemplate, Map<String, Object> vModels, boolean notificationFlag) { vModels.put("appUrl", appUrl); vModels.put("appEmail", appEmail); User user = userDao.getUser(SecurityUtils.getUser().getId()); List<Subscription> subscriptions = subscriptionDao.getSubscriptions(subscribable); List<String> addresses = new ArrayList<String>(); for (Subscription subscription : subscriptions) if (!subscription.isNotificationSent() && subscription.getSubscriber() != user) { addresses.add(subscription.getSubscriber().getEmail()); if (subscription.isNotificationSent() != notificationFlag) { subscription.setNotificationSent(notificationFlag); subscriptionDao.saveSubscription(subscription); }/* ww w. j a v a2 s .co m*/ } if (addresses.size() > 0) { String text = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, vTemplate, appEncoding, vModels); SimpleMailMessage email = new SimpleMailMessage(); email.setFrom(appEmail); email.setTo(appEmail); email.setSubject(subject); email.setText(text); massMailSender.send(email, addresses); } }
From source file:org.shredzone.cilla.service.notification.NotificationServiceImpl.java
/** * Send a {@link Notification} to a single {@link NotificationTarget}. * <p>/*from w w w . ja va 2 s. c om*/ * For the receiver's locale, the appropriate template is opened, it's placeholders * filled with the notification parameters, and the message sent to the target's * mail address. * * @param target * {@link NotificationTarget} to send to * @param notification * {@link Notification} to send */ private void sendToTarget(NotificationTarget target, Notification notification) throws CillaServiceException { try { Template template = freemarkerConfiguration.getTemplate(notification.getType() + ".ftl", target.getLocale()); StringWriter out = new StringWriter(); Environment env = template.createProcessingEnvironment(notification.getAttributes(), out, null); env.process(); out.close(); TemplateModel subjectTm = env.getVariable("subject"); SimpleMailMessage msg = new SimpleMailMessage(); msg.setFrom(sender); msg.setTo(target.getMail()); msg.setSubject(subjectTm != null ? subjectTm.toString() : ""); msg.setText(out.toString()); mailSender.send(msg); } catch (IOException | TemplateException ex) { log.error("Failed to process template ", ex); throw new CillaServiceException("Could not process template", ex); } }
From source file:org.smigo.user.MailHandler.java
public void sendAdminNotification(String subject, Object text) { final SimpleMailMessage simpleMailMessage = new SimpleMailMessage(); simpleMailMessage.setTo(notifierEmail); simpleMailMessage.setFrom(mailSenderUsername); simpleMailMessage.setSubject("[SMIGO] " + subject); simpleMailMessage.setText(text.toString()); senderExecutor.execute(() -> mailSender.send(simpleMailMessage)); }
From source file:org.smigo.user.MailHandler.java
public void sendClientMessage(String emailAddress, String subject, String text) { final SimpleMailMessage simpleMailMessage = new SimpleMailMessage(); simpleMailMessage.setTo(emailAddress); simpleMailMessage.setFrom(mailSenderUsername); simpleMailMessage.setSubject("Smigo " + subject); simpleMailMessage.setText(text);//from w w w . j av a 2 s. c om senderExecutor.execute(() -> mailSender.send(simpleMailMessage)); }
From source file:org.smigo.user.MailHandler.java
@PreDestroy public void sendShutdownAdminNotification() { final SimpleMailMessage simpleMailMessage = new SimpleMailMessage(); simpleMailMessage.setTo(notifierEmail); simpleMailMessage.setFrom(mailSenderUsername); simpleMailMessage.setSubject("[SMIGO] Server"); simpleMailMessage.setText("Server shutdown"); mailSender.send(simpleMailMessage);/*from w ww. j a v a 2s.c o m*/ }
From source file:com.admob.rocksteady.reactor.Email.java
/** * Handle the triggered event/* w w w . j a v a 2 s . c o m*/ * * @param newEvents the new events in the window * @param oldEvents the old events in the window */ public void update(EventBean[] newEvents, EventBean[] oldEvents) { if (newEvents == null) { return; } for (EventBean newEvent : newEvents) { try { String name = newEvent.get("name").toString(); String value = newEvent.get("value").toString(); String colo = newEvent.get("colo").toString(); SimpleMailMessage msg = new SimpleMailMessage(this.templateMessage); msg.setTo(this.recipient); logger.info(" event triggered - type " + type + " - " + colo + " - " + name + " - " + value); msg.setText(" event triggered - type " + type + " - " + colo + " - " + name + " - " + value); // this.mailSender.send(msg); } catch (Exception e) { logger.error("Problem with event: " + newEvent.toString()); } } }