Example usage for org.springframework.mail SimpleMailMessage setFrom

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

Introduction

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

Prototype

@Override
    public void setFrom(String from) 

Source Link

Usage

From source file:app.commons.EmailUtils.java

public static void send(String subject, String text) {
    try {/*from   w w w. j  a  va  2s.  c om*/
        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.impetus.kundera.ycsb.utils.MailUtils.java

private static void onSendEmail(Map<String, Double> delta, String operationType, String dataStore,
        String[] reciepents) {/*from  w  w w.j  a  va2s  .  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:ru.retbansk.utils.UsefulMethods.java

/**
 * For testing usage//w w  w.  j  ava2s. c  o m
 * 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.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);/*  ww w.j  a  v  a 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:com.rxx.common.util.MailUtil.java

/**
 * // w  w w.j a  v a 2 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:onlinevideo.aop.MailDispatcher.java

@Override
public void sendMail(String from, String to, String subject, String msg) {
    SimpleMailMessage message = new SimpleMailMessage();

    message.setFrom(from);
    message.setTo(to);//from  w w w.  j  a v a2 s. c o m
    message.setSubject(subject);
    message.setText(msg);
    mailSender.send(message);
}

From source file:pl.edu.agh.MailUtils.java

/**
 * Sends simple mail message//  w  w w. j a v  a  2 s.c  om
 */
public void sendMail(String from, String to, String subject, String content) {

    SimpleMailMessage message = new SimpleMailMessage();

    message.setFrom(from);
    message.setTo(to);
    message.setSubject(subject);
    message.setText(content);
    mailSender.send(message);
}

From source file:org.esupportail.pushnotification.service.Mail.java

public void sendMail(String from, String to, String subject, String msg) {
    //creating message
    SimpleMailMessage message = new SimpleMailMessage();
    message.setFrom(from);
    message.setTo(to);/*from w ww  . ja v  a2  s . c  o  m*/
    message.setSubject(subject);
    message.setText(msg);
    //sending message
    mailSender.send(message);
}

From source file:com.web.mavenproject6.other.Mailer.java

public void sendMail(String from, String to, String subject, String msg) {

    SimpleMailMessage message = new SimpleMailMessage();

    message.setFrom(from);
    message.setTo(to);//w w w  .jav  a2  s  .  co  m
    message.setSubject(subject);
    message.setText(msg);

    mailSender.send(message);
}

From source file:info.michaelchurch.arule.services.ContactEmailer.java

public void sendMessage(Comment comment) {

    String safeName = Jsoup.clean(comment.getName(), Whitelist.basic());
    String safeEmail = Jsoup.clean(comment.getEmail(), Whitelist.basic());
    String safePhone = Jsoup.clean(comment.getPhone(), Whitelist.basic());
    String safeComment = Jsoup.clean(comment.getEnquiryText(), Whitelist.basic());

    SimpleMailMessage message = new SimpleMailMessage();

    message.setFrom("arule@michaelchurch.info");
    message.setTo("michaelchurch256@hotmail.com");
    message.setSubject("New feedback from website");
    message.setText("User's name: " + safeName + "\n\nUser's email address: " + safeEmail
            + "\n\nUser's phone number: " + safePhone + "\n\nUser's enquiry: " + safeComment);

    mailSender.send(message);//www.j  a  v  a 2s . com

}