List of usage examples for org.springframework.mail SimpleMailMessage setFrom
@Override public void setFrom(String from)
From source file:com.przemo.projectmanagementweb.services.MailService.java
void sendAccountConfirmationEmail(String email, String link) { try {/* ww w .j a va 2s. c om*/ SimpleMailMessage msg = new SimpleMailMessage(); msg.setSubject("Project Management System account activation."); msg.setFrom("info@pncomp.com"); msg.setTo(email); msg.setText("Please click the following below to activate your account. " + link); try { mailSender.send(msg); } catch (MailException mex) { LoggerFactory.getLogger(getClass()).error("From Mail Service MailException: "); LoggerFactory.getLogger(getClass()).error(mex.getMessage()); } } catch (Exception ex) { LoggerFactory.getLogger(getClass()).error("From Mail Service Exception: "); } }
From source file:nl.han.dare2date.service.notifier.UserNotifier.java
public void notify(Registration registration) { if (registration == null) { throw new IllegalArgumentException(); }/* ww w.j a va 2 s . c o m*/ User user = registration.getUser(); StringBuffer sbText = new StringBuffer(); sbText.append(String.format("Hoi %s", user.getFirstname())); sbText.append("\n\n"); sbText.append("Welkom bij Dare2Date."); sbText.append("\n\n"); sbText.append("Hierbij bevestigen wij uw registratie bij Dare2Date."); sbText.append("\n\n"); sbText.append("Met vriendelijke groet,"); sbText.append("\n\n"); sbText.append("Het Dare2Date Team"); SimpleMailMessage mail = new SimpleMailMessage(); mail.setTo(user.getEmail()); mail.setFrom(fromEmail); mail.setSubject("Je registratie bij Dare2Date"); mail.setText(sbText.toString()); mailSender.send(mail); }
From source file:de.codecentric.boot.admin.notify.MailNotifier.java
@Override protected void doNotify(ClientApplicationStatusChangedEvent event) { EvaluationContext context = new StandardEvaluationContext(event); SimpleMailMessage message = new SimpleMailMessage(); message.setTo(to);//from w ww .j a v a2s . c om message.setFrom(from); message.setSubject(subject.getValue(context, String.class)); message.setText(text.getValue(context, String.class)); message.setCc(cc); sender.send(message); }
From source file:ar.com.zauber.commons.message.impl.mail.SimpleEmailNotificationStrategy.java
/** @see NotificationStrategy#execute(NotificationAddress[], Message) */ //CHECKSTYLE:ALL:OFF public void execute(final NotificationAddress[] addresses, final Message message) { final SimpleMailMessage mail = new SimpleMailMessage(); mail.setFrom(getFromAddress().getEmailStr()); mail.setTo(getEmailAddresses(addresses)); mail.setReplyTo(getEmailAddress(message.getReplyToAddress())); mail.setSubject(message.getSubject()); mail.setText(message.getContent());/*from ww w .j a v a 2s . c o m*/ mailSender.send(mail); }
From source file:org.benassi.bookeshop.web.interceptors.ConfirmationEmailInterceptor.java
@Override public String intercept(ActionInvocation invocation) throws Exception { invocation.invoke();/* w w w . j a v a2s . c om*/ Map<String, Object> session = ActionContext.getContext().getSession(); loggedCustomer = (Customer) session.get(BookeshopConstants.SESSION_USER); Order order = ((CheckoutAction) invocation.getAction()).getOrder(); order.setFormattedDate(orderUtil.formatDate(order.getDate())); order.setFormattedTotal(orderUtil.formatTotal(order.getTotal())); Map model = new HashMap(); model.put("customer", loggedCustomer); model.put("order", order); String result = null; try { result = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "velocity/orderConfirmation.vm", model); } catch (VelocityException e) { logger.error("Error in generating confirmation email from velocity template.", e); return Action.ERROR; } SimpleMailMessage message = new SimpleMailMessage(); message.setFrom(messageProvider.getMessage("web.checkout.mail.from", null, null, null)); message.setSentDate(new Date()); message.setTo(loggedCustomer.getEmail()); message.setSubject(messageProvider.getMessage("web.checkout.mail.object", new Object[] { order.getOrderId() }, null, null)); message.setText(result); mailSender.send(message); return Action.SUCCESS; }
From source file:com.netflix.genie.core.services.impl.MailServiceImpl.java
@Override public void sendEmail(@NotBlank(message = "Cannot send email to blank address.") final String toEmail, @NotBlank(message = "Subject cannot be empty") final String subject, final String body) throws GenieException { final SimpleMailMessage simpleMailMessage = new SimpleMailMessage(); simpleMailMessage.setTo(toEmail);//w w w . j a va2s.co m simpleMailMessage.setFrom(this.fromAddress); simpleMailMessage.setSubject(subject); simpleMailMessage.setText(body); // check if body is not empty if (StringUtils.isNotBlank(body)) { simpleMailMessage.setText(body); } try { this.javaMailSender.send(simpleMailMessage); } catch (final MailException me) { throw new GenieServerException("Failure to send email: " + me); } }
From source file:net.maritimecloud.identityregistry.utils.EmailUtil.java
public void sendOrgAwaitingApprovalEmail(String sendTo, String orgName) throws MailException { if (sendTo == null || sendTo.trim().isEmpty()) { throw new IllegalArgumentException("No email address!"); }// w w w . j a v a2 s .c o m SimpleMailMessage msg = new SimpleMailMessage(); msg.setTo(sendTo); msg.setFrom(from); msg.setSubject(String.format(orgAwaitingApprovalSubject, orgName)); msg.setText(String.format(orgAwaitingApprovalText, orgName)); this.mailSender.send(msg); }
From source file:net.maritimecloud.identityregistry.utils.EmailUtil.java
public void sendAdminOrgAwaitingApprovalEmail(String orgName) throws MailException { SimpleMailMessage msg = new SimpleMailMessage(); msg.setTo(adminEmail);/*from w w w . j a v a 2 s .c o m*/ msg.setFrom(from); msg.setSubject(String.format(orgAwaitingApprovalSubject, orgName)); msg.setText(String.format(adminOrgAwaitingApprovalText, orgName)); this.mailSender.send(msg); }
From source file:net.maritimecloud.identityregistry.utils.EmailUtil.java
public void sendUserCreatedEmail(String sendTo, String userName, String loginName, String loginPassword) throws MailException { if (sendTo == null || sendTo.trim().isEmpty()) { throw new IllegalArgumentException("No email address!"); }//from w ww . j a v a 2s .co m SimpleMailMessage msg = new SimpleMailMessage(); msg.setTo(sendTo); msg.setFrom(from); msg.setSubject(createdUserSubject); msg.setText(String.format(createdUserText, userName, loginName, loginPassword, portalUrl, projectIDPName)); this.mailSender.send(msg); }
From source file:ar.com.zauber.commons.spring.mail.EntityManagerMailSenderTest.java
/** test */ @Test/*from w ww . ja v a 2 s .c o m*/ public final void testFoo() { final SimpleMailMessage message = new SimpleMailMessage(); message.setBcc("bcc"); message.setCc("cc"); message.setFrom("from"); message.setReplyTo("reply"); message.setText("foo"); message.setTo("a"); ms.send(message); em.flush(); em.clear(); final List<RepositoryMailMessage> l = em.createQuery("from RepositoryMailMessage").getResultList(); assertEquals(1, l.size()); final RepositoryMailMessage m = l.get(0); assertEquals("bcc", m.getBcc()); assertEquals("cc", m.getCc()); assertEquals("from", m.getFrom()); assertEquals("reply", m.getReplyTo()); assertEquals("foo", m.getText()); assertEquals("a", m.getTo()); }