Example usage for org.springframework.mail SimpleMailMessage setSubject

List of usage examples for org.springframework.mail SimpleMailMessage setSubject

Introduction

In this page you can find the example usage for org.springframework.mail SimpleMailMessage setSubject.

Prototype

@Override
    public void setSubject(String subject) 

Source Link

Usage

From source file:cs544.letmegiveexam.util.EmailManager.java

/**
 * This method will send email to customer/faculty/admin etc
 *
 * @param mailSender Java email sender/*from  w  w w  .  ja v  a2s  . c om*/
 * @param subject Email subject
 * @param body Email body
 * @param mailTo Mail to information
 */
public static void sendEmail(JavaMailSender mailSender, String subject, String body, String mailTo) {

    SimpleMailMessage email = new SimpleMailMessage();

    email.setText(body);
    email.setTo(mailTo);
    email.setSubject(subject);
    mailSender.send(email);
}

From source file:app.commons.EmailUtils.java

public static void send(String subject, String text) {
    try {/*from  w  w w .  java2 s.co  m*/
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(FROM_EMAIL_ADRRESS);
        message.setTo(TO_EMAIL_ADRRESS);
        message.setSubject(subject);
        message.setText(text);

        mailSender.send(message);
    } catch (MailSendException e) {
    } catch (MailException e) {
    }
}

From source file:com.saviour.poweryoga.util.EmailManager.java

/**
 * This method will send email to customer/faculty/admin etc
 *
 * @param mailSender Java email sender//www  .  j  av a 2 s.co m
 * @param subject Email subject
 * @param body Email body
 * @param mailTo Mail to information
 */
public static void sendEmail(JavaMailSender mailSender, String subject, String body, String mailTo) {

    SimpleMailMessage email = new SimpleMailMessage();
    //String link = "http://localhost:8080/mycompany.com/activation/" + encodedUser;
    email.setText(body);
    email.setTo(mailTo);
    email.setSubject(subject);
    mailSender.send(email);
}

From source file:ru.retbansk.utils.UsefulMethods.java

/**
 * For testing usage/*from   ww  w  .j av  a  2s. c  om*/
 * Sending to mr.server.serverovich@yandex.ru four reports.
 * <p> One is invalid. Two from one email address
 * @throws InterruptedException I used Thread.sleep method in be ensure in the order of sending
 */
public static void populate() throws InterruptedException {
    JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
    SimpleMailMessage msg = new SimpleMailMessage();
    msg.setFrom("another.tester@yandex.ru");
    msg.setSubject("Test report 4");
    msg.setTo("mr.server.serverovich@yandex.ru");
    msg.setText("   ,  ??, 8");
    mailSender.setHost("smtp.yandex.ru");
    mailSender.setUsername("another.tester@yandex.ru");
    mailSender.setPassword("tester");
    mailSender.send(msg);
    SimpleMailMessage[] msgs = new SimpleMailMessage[3];
    for (int i = 0; i < 3; i++) {
        msgs[i] = new SimpleMailMessage();
        msgs[i].setFrom("tester.testerovich@yandex.ru");
        msgs[i].setSubject("Test report " + (i + 1));
        msgs[i].setTo("mr.server.serverovich@yandex.ru");
    }
    msgs[2].setText(
            "helping Google with Android, in process, 7\nmain job/ in process/1\nnothing actually. done. 3");
    msgs[1].setText("Testing error report");
    msgs[0].setText(", , 2\n,  ??, 6");
    mailSender.setUsername("tester.testerovich@yandex.ru");
    mailSender.setPassword("tester");
    Thread.sleep(1000);
    mailSender.send(msgs[0]);
    Thread.sleep(1000);
    mailSender.send(msgs[1]);
    Thread.sleep(1000);
    mailSender.send(msgs[2]);

}

From source file:com.impetus.kundera.ycsb.utils.MailUtils.java

private static void onSendEmail(Map<String, Double> delta, String operationType, String dataStore,
        String[] reciepents) {//from w ww.  j  av  a  2 s.  co  m
    String host = "192.168.150.5";
    JavaMailSenderImpl emailSender = new JavaMailSenderImpl();
    emailSender.setHost(host);
    // emailSender.setPort(port);
    emailSender.setUsername("noreply-kundea@impetus.co.in");
    SimpleMailMessage mail = new SimpleMailMessage();
    mail.setTo(reciepents);
    mail.setFrom("noreply-kundea@impetus.co.in");

    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:com.rxx.common.util.MailUtil.java

/**
 * /*from www.  ja v a2s. c om*/
 *
 * @param host 
 * @param port
 * @param userName
 * @param password
 * @param title
 * @param content
 * @param toUser
 */
public static void sendText(String host, int port, String userName, String password, String title,
        String content, String[] toUser) {
    JavaMailSenderImpl senderImpl = new JavaMailSenderImpl();
    // mail server
    senderImpl.setHost(host);
    senderImpl.setPort(port);
    // 
    SimpleMailMessage mailMessage = new SimpleMailMessage();
    //  
    // String[] array = new String[] {"sun111@163.com","sun222@sohu.com"};
    // mailMessage.setTo(array);
    mailMessage.setTo(toUser);
    mailMessage.setFrom(userName);
    mailMessage.setSubject(title);
    mailMessage.setText(content);

    senderImpl.setUsername(userName); // ,username
    senderImpl.setPassword(password); // , password

    Properties prop = new Properties();
    prop.put(" mail.smtp.auth ", " true "); // true,
    prop.put(" mail.smtp.timeout ", " 25000 ");
    senderImpl.setJavaMailProperties(prop);
    // 
    senderImpl.send(mailMessage);
}

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);//  w  w  w . j a v  a  2s.  c  o  m
    // 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:com.przemo.projectmanagementweb.services.MailService.java

void sendAccountConfirmationEmail(String email, String link) {
    try {/*from   www  . ja  v a  2s  .com*/
        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:com.lnu.agile.mail.ApplicationMailer.java

@Override
public void sendMail(String to, String subject, String body) {
    SimpleMailMessage message = new SimpleMailMessage();
    message.setTo(to);/*ww w . j  a  v a2s . c o  m*/
    message.setSubject(subject);
    message.setText(body);
    mailSender.send(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);
    message.setFrom(fromEmail);/*from   www  .  j  a v a  2  s.  c  o  m*/
    message.setTo(toEmail);
    String emailText = createEmailText(model);
    message.setText(emailText);
    mailSender.send(message);
}