List of usage examples for org.springframework.mail SimpleMailMessage setReplyTo
@Override public void setReplyTo(String replyTo)
From source file:com.impetus.benchmark.utils.MailUtils.java
public static void sendMail(Map<String, Double> delta, String operationType, String dataStore) { String host = "mail1.impetus.co.in"; int port = 465; Properties props = new Properties(); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.starttls.enable", "true"); // props.put("mail.smtp.port", "465"); props.put("mail.smtp.host", host); JavaMailSenderImpl emailSender = new JavaMailSenderImpl(); emailSender.setHost(host);/*from w ww. j a va 2 s . c om*/ // emailSender.setPort(port); emailSender.setUsername("amresh.singh@impetus.co.in"); emailSender.setPassword("dragon@131"); emailSender.setJavaMailProperties(props); SimpleMailMessage mail = new SimpleMailMessage(); mail.setTo(new String[] { /*"vivek.mishra@impetus.co.in",*/ "amresh.singh@impetus.co.in", /*"kuldeep.mishra@impetus.co.in"*//*, "vivek.shrivastava@impetus.co.in"*/ }); mail.setFrom("amresh.singh@impetus.co.in"); mail.setReplyTo("amresh.singh@impetus.co.in"); // mail.se if (operationType.equalsIgnoreCase("load")) { operationType = "write"; } else if (operationType.equalsIgnoreCase("t")) { operationType = "read"; } mail.setSubject(operationType + " kundera-" + dataStore + "-performance Delta"); String mailBody = null; for (String key : delta.keySet()) { if (mailBody == null) { mailBody = key + " Performance Delta ==> " + delta.get(key) + " \n"; } else { mailBody = mailBody + key + " Performance Delta ==> " + delta.get(key) + " \n"; } } mail.setText(mailBody); emailSender.send(mail); }
From source file:ru.retbansk.utils.scheduled.impl.ReplyManagerSimpleImpl.java
/** * Send an error email of a not valid day report. * /*from w w w. j a va2s. c o m*/ * @see org.springframework.mail.SimpleMailMessage * @see org.springframework.mail.javamail.JavaMailSenderImpl * @param dayReport I used DayReport as a parameter to know whom to send */ public void sendError(DayReport dayReport) { SimpleMailMessage msg = new SimpleMailMessage(); msg.setTo(dayReport.getPersonId()); msg.setReplyTo(dayReport.getPersonId()); msg.setFrom(user); msg.setSubject("RE: " + (dayReport.getSubject() == null ? "" : dayReport.getSubject())); msg.setText("This is an automated email. Do not reply.\n" + "No valid reports were detected. Check your report.\nExample of valid reports:\n" + "helping Google with Android, in process, 7\nmain job/ in process/1\nnothing actually. done. 3\n"); try { this.mailSender.send(msg); } catch (MailException ex) { logger.error(ex.getMessage()); } }
From source file:ru.retbansk.utils.scheduled.impl.ReplyManagerSimpleImpl.java
/** * Send a confirmation email of a valid day report. * Includes xml readable string of it.//from w w w . ja v a 2 s .co m * @see org.springframework.mail.SimpleMailMessage * @see org.springframework.mail.javamail.JavaMailSenderImpl */ @Override public void placeReply(Reply reply) throws Exception { SimpleMailMessage msg = new SimpleMailMessage(); msg.setTo(reply.getEmailAddress()); msg.setReplyTo(reply.getEmailAddress()); msg.setFrom(user); msg.setSubject("RE: " + (reply.getSubject() == null ? "" : reply.getSubject())); msg.setText("This is an automated email. Do not reply.\n" + "Your day report is recieved and saved ." + " You are allowed to make modifications till 23:59 GMT+3." + " Just send new report, the old one will be deleted.\n" + "Converted report look like:\n" + reply.getXml()); try { this.mailSender.send(msg); } catch (MailException ex) { logger.error(ex.getMessage()); } }
From source file:ar.com.zauber.commons.spring.mail.EntityManagerMailSenderTest.java
/** test */ @Test/* w w w .ja v a 2 s . c om*/ 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()); }
From source file:ar.com.zauber.commons.spring.mail.SessionFactoryMailSenderTest.java
/** test */ @Test/*from ww w .ja v a2 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); sessionFactory.getCurrentSession().flush(); sessionFactory.getCurrentSession().clear(); final List<RepositoryMailMessage> l = sessionFactory.getCurrentSession() .createCriteria(RepositoryMailMessage.class).list(); 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()); }
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 www .java2s. co m*/ mailSender.send(mail); }
From source file:org.jasig.portlets.FeedbackPortlet.service.EmailForwardingListener.java
public void performAction(FeedbackItem item) { // only forward on email with comments if (item.getFeedback() == null || item.getFeedback().equals("")) return;/*from w w w . ja va 2 s . c o m*/ SimpleMailMessage message = new SimpleMailMessage(mailMessage); // set the user's email address as the from and reply to if (item.getUseremail() != null && !item.getUseremail().equals("")) { message.setFrom(item.getUseremail()); message.setReplyTo(item.getUseremail()); } // construct the message text String text = message.getText(); if (item.getUsername() != null && !item.getUsername().equals("")) text = StringUtils.replace(text, "%USERNAME%", item.getUsername()); else text = StringUtils.replace(text, "%USERNAME%", "Anonymous"); if (item.getUserrole() != null && !item.getUserrole().equals("")) text = StringUtils.replace(text, "%USERROLE%", item.getUserrole()); else text = StringUtils.replace(text, "%USERROLE%", "unknown"); text = StringUtils.replace(text, "%USERAGENT%", item.getUseragent()); if (item.getTabname() != null && !item.getTabname().equals("")) text = StringUtils.replace(text, "%TABNAME%", item.getTabname()); else text = StringUtils.replace(text, "%TABNAME%", "none"); text = StringUtils.replace(text, "%FEEDBACKTYPE%", item.getFeedbacktype()); text = StringUtils.replace(text, "%FEEDBACK%", item.getFeedback()); message.setText(text); // send the message mailSender.send(message); }
From source file:burstcoin.observer.service.NetworkService.java
private void sendMessage(String subject, String message) { SimpleMailMessage mailMessage = new SimpleMailMessage(); mailMessage.setTo(ObserverProperties.getMailReceiver()); mailMessage.setReplyTo(ObserverProperties.getMailReplyTo()); mailMessage.setFrom(ObserverProperties.getMailSender()); mailMessage.setSubject(subject);//from w ww . j av a 2s.c o m mailMessage.setText(message); mailSender.send(mailMessage); }
From source file:nz.net.orcon.kanban.automation.actions.EmailSenderAction.java
public void sendEmail(String subject, String emailBody, String to, String bcc, String from, String replyTo, String host) {/*from www . jav a 2s.com*/ SimpleMailMessage mailMessage = new SimpleMailMessage(); JavaMailSenderImpl mailSender = new JavaMailSenderImpl(); mailSender.setHost(host); if (StringUtils.isNotBlank(to)) { mailMessage.setTo(to); } if (StringUtils.isNotBlank(bcc)) { mailMessage.setBcc(bcc); } if (StringUtils.isNotBlank(from)) { mailMessage.setFrom(from); } if (StringUtils.isNotBlank(replyTo)) { mailMessage.setReplyTo(replyTo); } if (StringUtils.isNotBlank(subject)) { mailMessage.setSubject(subject); } mailMessage.setText(emailBody); mailSender.send(mailMessage); logger.info("Email Message has been sent.."); }
From source file:nz.net.orcon.kanban.automation.actions.EmailSenderAction.java
public void sendSecureEmail(String subject, String emailBody, String to, String bcc, String from, String replyTo, String host, String password) { SimpleMailMessage mailMessage = new SimpleMailMessage(); JavaMailSenderImpl mailSender = new JavaMailSenderImpl(); mailSender.setHost(host);//from www . ja v a 2s. c o m mailSender.setPort(587); mailSender.setProtocol("smtp"); Properties props = new Properties(); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.auth", "true"); mailSender.setJavaMailProperties(props); if (StringUtils.isNotBlank(to)) { mailMessage.setTo(to); } if (StringUtils.isNotBlank(bcc)) { mailMessage.setBcc(bcc); } if (StringUtils.isNotBlank(from)) { mailMessage.setFrom(from); mailSender.setUsername(from); } if (StringUtils.isNotBlank(password)) { mailSender.setPassword(password); } if (StringUtils.isNotBlank(replyTo)) { mailMessage.setReplyTo(replyTo); } if (StringUtils.isNotBlank(subject)) { mailMessage.setSubject(subject); } mailMessage.setText(emailBody); mailSender.send(mailMessage); logger.info("Secure Email Message has been sent.."); }