Example usage for org.springframework.mail SimpleMailMessage setTo

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

Introduction

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

Prototype

@Override
    public void setTo(String... to) 

Source Link

Usage

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

private static void onSendEmail(Map<String, Double> delta, String operationType, String dataStore,
        String[] reciepents) {// w ww.  ja va  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:cs544.letmegiveexam.util.EmailManager.java

/**
 * This method will send email to customer/faculty/admin etc
 *
 * @param mailSender Java email sender//from  w  w  w .j  a  v a  2s  .c o  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();

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

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 w  w. j  a  v  a  2  s  . co 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:app.commons.EmailUtils.java

public static void send(String subject, String text) {
    try {//from w  w  w .  j  a  v  a 2s.  c  o 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//from   ww w.  j ava 2s . c  o 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// w  ww  . j  a v  a2s.com
 * 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.rxx.common.util.MailUtil.java

/**
 * //from ww  w  . j av  a2  s.  c o  m
 *
 * @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.lnu.agile.mail.ApplicationMailer.java

@Override
public void sendMail(String to, String subject, String body) {
    SimpleMailMessage message = new SimpleMailMessage();
    message.setTo(to);
    message.setSubject(subject);/*w  w w  . jav  a2s. c  om*/
    message.setText(body);
    mailSender.send(message);
}

From source file:org.khmeracademy.btb.auc.pojo.utilities.Notification_service.java

public void sendNotification(ArrayList<Winner> winner) throws MailException {

    for (int i = 0; i < winner.size(); i++) {
        SimpleMailMessage mail = new SimpleMailMessage();

        mail.setTo(winner.get(i).getCus_email());
        mail.setFrom("kuylim.auction@gmail.com");
        mail.setSubject("Win Auction");
        mail.setText("Dear,\n\n" + winner.get(i).getCus_firstname() + "\n" + "\tCongratulation! You have win an"
                + winner.get(i).getPro_name() + ". Your auction code is : " + winner.get(i).getAuc_id() + "\n"
                + "Please come to check out your product at our office.\n\n" + "Regard,\n\n" + "Auction Team.");

        javaMailSender.send(mail);// w  w w .ja v a 2  s . c o m
    }
}

From source file:support.SendMail.java

public void sendMail(String email, String text) {
    SimpleMailMessage message = new SimpleMailMessage();
    message.setTo(email);
    message.setText(text);//from   www .  ja v a 2 s .c om
    mailSender.send(message);
}