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: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 a2 s  .c  om
 * @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:com.marcosanta.service.impl.RecuperaServiceImpl.java

@Override
public boolean enviaCorreo(String correo) {
    try {/*from ww  w  .ja  v a2  s. c  o m*/
        String contrasena = generaContrasena();
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom("edcgamer@hotmail.com");
        message.setTo(correo);
        message.setSubject("Contrasea temporal azteca ");
        message.setText("Su nueva contrasea es: " + contrasena
                + " se recomienda cambiar de contrasea una vez conectado.\n"
                + "1.    Inicie sesin con su usuario y la contrasea que se le proporciona en este correo.\n"
                + "\n"
                + "Despus de realizar este cambio, la contrasea temporal dejara de ser vlida para iniciar sesin.");
        mailSender.send(message);
    } catch (Exception ex) {
        return false;
    }
    return true;
}

From source file:com.mycompany.capstone.dao.QuoteDaoDbImpl.java

@Override
public Quote create(Quote quote) {

    jdbcTemplate.update(SQL_INSERT_QUOTE, quote.getFirstName(), quote.getLastName(), quote.getEmail(),
            quote.getYear(), quote.getSelectedMake(), quote.getSelectedModel(), quote.getDescription());

    Integer id = jdbcTemplate.queryForObject("SELECT LAST_INSERT_ID()", Integer.class);

    quote.setId(id);/*from   w  w w. ja va 2s . com*/

    Properties props = (Properties) System.getProperties().clone();
    props.put("mail.smtp.host", "host");
    props.setProperty("mail.smtp.port", "587");
    props.put("mail.smtp.auth", true);

    //Bypass the SSL authentication
    props.put("mail.smtp.ssl.enable", false);
    props.put("mail.smtp.starttls.enable", false);

    SimpleMailMessage msg = new SimpleMailMessage(this.templateMessage);
    msg.setTo("bennettglob@gmail.com");
    //        msg.setRecipients(Message.RecipientType.TO, ("bennettglob@gmail.com" + quote.getEmail()));

    msg.setText("test");
    try {
        this.mailSender.send(msg);
    } catch (MailException ex) {
        // simply log it and go on...
        System.err.println(ex.getMessage());
    }

    return quote;

}

From source file:com.precioustech.fxtrading.tradingbot.events.notification.email.EventEmailNotifier.java

@Subscribe
@AllowConcurrentEvents//from   w  w  w  .  j av a  2  s.  c  om
public void notifyByEmail(EventPayLoad<T> payLoad) {
    Preconditions.checkNotNull(payLoad);
    EmailContentGenerator<T> emailContentGenerator = eventEmailContentGeneratorMap.get(payLoad.getEvent());
    if (emailContentGenerator != null) {
        EmailPayLoad emailPayLoad = emailContentGenerator.generate(payLoad);
        SimpleMailMessage msg = new SimpleMailMessage();
        msg.setSubject(emailPayLoad.getSubject());
        msg.setTo(tradingConfig.getMailTo());
        msg.setText(emailPayLoad.getBody());
        this.mailSender.send(msg);
    } else {
        LOG.warn("No email content generator found for event:" + payLoad.getEvent().name());
    }
}

From source file:it.geosolutions.opensdi2.email.OpenSDIMailer.java

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

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

From source file:com.springsource.greenhouse.signup.WelcomeMailTransformer.java

/**
 * Perform the Account to MailMessage transformation.
 *///from   w  ww  . j  a  v  a  2  s. c o m
@Transformer
public MailMessage welcomeMail(Account account) {
    SimpleMailMessage mailMessage = new SimpleMailMessage();
    mailMessage.setFrom("Greenhouse <noreply@springsource.com>");
    mailMessage.setTo(account.getEmail());
    mailMessage.setSubject("Welcome to the Greenhouse!");
    StringTemplate textTemplate;
    textTemplate = welcomeTemplateFactory.getStringTemplate();
    textTemplate.put("firstName", account.getFirstName());
    textTemplate.put("profileUrl", account.getProfileUrl());
    mailMessage.setText(textTemplate.render());
    return mailMessage;
}

From source file:com.mycompany.spring.batch.mail.demo.batch.SampleBatchApplication.java

@Bean
public ItemProcessor processor() {
    ItemProcessor processor = new ItemProcessor() {

        @Override/* w  w  w  .ja v a  2 s  . co m*/
        public SimpleMailMessage process(Object item) throws Exception {
            SimpleMailMessage message = new SimpleMailMessage();
            message.setFrom("root@localhost.localdomain");
            message.setTo("c7@localhost.localdomain");
            message.setSubject(item.toString());
            message.setSentDate(new Date());
            message.setText("Hello " + item.toString());
            System.out.println("Sending message with subject: " + item);
            return message;
        }
    };
    return processor;
}

From source file:org.openregistry.core.service.DefaultEmailIdentifierNotificationStrategy.java

public void notifyPerson(Person person, Role role, Type addressType, Identifier idToNotifyAbout,
        String activationKeyString) throws IllegalArgumentException, IllegalStateException {

    if (person == null) {
        throw new IllegalArgumentException("Person must be specified");
    }//  w  w  w .j av a2s.  c  om
    if (idToNotifyAbout == null) {
        throw new IllegalArgumentException("Identifier must be specified");
    }

    Name officialName = person.getOfficialName();

    SimpleMailMessage msg = new SimpleMailMessage();

    msg.setTo(findEmailAddressesForNotification(person, role, addressType));
    msg.setFrom(messageSource.getMessage("activation.notify.from", null, null));
    msg.setSubject(messageSource.getMessage("activation.notify.subject", null, null));
    String greeting = (officialName == null) ? "" : officialName.getFormattedName();
    msg.setText(messageSource.getMessage("activation.notify.body",
            new String[] { greeting, idToNotifyAbout.getValue(), activationKeyString }, null));
    mailSender.send(msg);
}

From source file:com.springsource.greenhouse.reset.ResetPasswordMailMessageConverter.java

public SimpleMailMessage convert(ResetPasswordRequest request) {
    SimpleMailMessage mailMessage = new SimpleMailMessage();
    mailMessage.setFrom("Greenhouse <noreply@springsource.com>");
    mailMessage.setTo(request.getAccount().getEmail());
    StringTemplate textTemplate;//  w  w  w.j av  a  2 s  .  c o m
    mailMessage.setSubject("Reset your Greenhouse password");
    textTemplate = resetTemplateFactory.getStringTemplate();
    textTemplate.put("firstName", request.getAccount().getFirstName());
    textTemplate.put("resetUrl", resetUriTemplate.expand(request.getToken()));
    mailMessage.setText(textTemplate.render());
    return mailMessage;
}

From source file:org.tsm.concharto.lab.LabJavaMail.java

private void sendConfirmationEmail(User user) {
    //mailSender.setHost("skipper");
    SimpleMailMessage message = new SimpleMailMessage();
    message.setTo(user.getEmail());
    String messageText = StringUtils.replace(WELCOME_MESSAGE, PARAM_NAME, user.getUsername());
    message.setText(messageText);/*  w  w  w .  jav  a 2  s . c  o m*/
    message.setSubject(WELCOME_SUBJECT);
    message.setFrom("<Concharto Notifications> notify@concharto.com");

    JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
    MimeMessage mimeMessage = mailSender.createMimeMessage();
    InternetAddress from = new InternetAddress();
    from.setAddress("notify@concharto.com");
    InternetAddress to = new InternetAddress();
    to.setAddress(user.getEmail());
    try {
        from.setPersonal("Concharto Notifications");
        mimeMessage.addRecipient(Message.RecipientType.TO, to);
        mimeMessage.setSubject(WELCOME_SUBJECT);
        mimeMessage.setText(messageText);
        mimeMessage.setFrom(from);
    } catch (UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (MessagingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    mailSender.setHost("localhost");
    mailSender.send(mimeMessage);

    /*
    Confirm your registration with Concharto
            
    Hello sanmi,
            
    Welcome to the Concharto community!
            
    Please click on this link to confirm your registration: http://www.concharto.com/member/confirm.htm?id=:confirmation 
            
    You can find out more about us at http://wiki.concharto.com/wiki/About.
            
    If you were not expecting this email, just ignore it, no further action is required to terminate the request.
     */
}