Search in sources :

Example 71 with SimpleMailMessage

use of org.springframework.mail.SimpleMailMessage in project bitcampSCOpen2017 by ryuyj.

the class SimpleRegistrationNotifier method sendMail.

public void sendMail(String memberemail) {
    SimpleMailMessage message = new SimpleMailMessage();
    message.setSubject("[Simple] 회원 가입 안내");
    message.setFrom("isisncorp@gmail.com");
    message.setText("회원 가입을 환영합니다.");
    message.setTo(memberemail);
    try {
        mailSender.send(message);
    } catch (MailException ex) {
        ex.printStackTrace();
    }
}
Also used : SimpleMailMessage(org.springframework.mail.SimpleMailMessage) MailException(org.springframework.mail.MailException)

Example 72 with SimpleMailMessage

use of org.springframework.mail.SimpleMailMessage in project java-examples by urvanov-ru.

the class App method main.

public static void main(String[] args) {
    try (GenericXmlApplicationContext context = new GenericXmlApplicationContext()) {
        context.load("classpath:applicationContext.xml");
        context.refresh();
        JavaMailSender mailSender = context.getBean("mailSender", JavaMailSender.class);
        SimpleMailMessage templateMessage = context.getBean("templateMessage", SimpleMailMessage.class);
        // Создаём потокобезопасную копию шаблона.
        SimpleMailMessage mailMessage = new SimpleMailMessage(templateMessage);
        // TODO: Сюда напишите свой e-mail получателя.
        mailMessage.setTo("ouhb93u4hng9hndf9@mail.ru");
        mailMessage.setText("Привет, товарищи. Присылаю вам письмо...");
        try {
            mailSender.send(mailMessage);
            System.out.println("Mail sended");
        } catch (MailException mailException) {
            System.out.println("Mail send failed.");
            mailException.printStackTrace();
        }
    }
}
Also used : SimpleMailMessage(org.springframework.mail.SimpleMailMessage) MailException(org.springframework.mail.MailException) JavaMailSender(org.springframework.mail.javamail.JavaMailSender) GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext)

Example 73 with SimpleMailMessage

use of org.springframework.mail.SimpleMailMessage in project trainning by fernandotomasio.

the class SystemServiceSimpleImpl method sendMail.

@Override
@Transactional
public void sendMail(String to, String subject, String text) {
    SimpleMailMessage message = new SimpleMailMessage();
    message.setFrom("sgc@decea.intraer");
    message.setTo(to);
    message.setSubject(subject);
    message.setText(text);
    if (to != null) {
        try {
            mailSender.send(message);
        } catch (MailException e) {
            Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, e);
        }
    }
}
Also used : SimpleMailMessage(org.springframework.mail.SimpleMailMessage) MailException(org.springframework.mail.MailException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 74 with SimpleMailMessage

use of org.springframework.mail.SimpleMailMessage in project Gemma by PavlidisLab.

the class MailEngineImpl method sendAdminMessage.

/**
 * Sends a message to the gemma administrator as defined in the Gemma.properties file
 */
@Override
public void sendAdminMessage(String bodyText, String subject) {
    if ((bodyText == null) && (subject == null)) {
        MailEngineImpl.log.warn("Not sending empty email, both subject and body are null");
        return;
    }
    MailEngineImpl.log.info("Sending email notification to administrator regarding: " + subject);
    SimpleMailMessage msg = new SimpleMailMessage();
    msg.setTo(Settings.getAdminEmailAddress());
    msg.setFrom(Settings.getAdminEmailAddress());
    msg.setSubject(subject);
    msg.setText(bodyText);
    this.send(msg);
}
Also used : SimpleMailMessage(org.springframework.mail.SimpleMailMessage)

Example 75 with SimpleMailMessage

use of org.springframework.mail.SimpleMailMessage in project Gemma by PavlidisLab.

the class TableMaintenanceUtilImpl method sendEmail.

private void sendEmail(Gene2CsStatus results) {
    if (!sendEmail)
        return;
    SimpleMailMessage msg = new SimpleMailMessage();
    String adminEmailAddress = Settings.getAdminEmailAddress();
    if (StringUtils.isBlank(adminEmailAddress)) {
        TableMaintenanceUtilImpl.log.warn("No administrator email address could be found, so gene2cs status email will not be sent.");
        return;
    }
    msg.setTo(adminEmailAddress);
    msg.setSubject("Gene2Cs update status.");
    msg.setText("Gene2Cs updating was run.\n" + results.getAnnotation());
    mailEngine.send(msg);
    TableMaintenanceUtilImpl.log.info("Email notification sent to " + adminEmailAddress);
}
Also used : SimpleMailMessage(org.springframework.mail.SimpleMailMessage)

Aggregations

SimpleMailMessage (org.springframework.mail.SimpleMailMessage)106 MailException (org.springframework.mail.MailException)17 Test (org.junit.Test)13 Test (org.testng.annotations.Test)7 Test (org.junit.jupiter.api.Test)6 User (org.molgenis.data.security.auth.User)5 JavaMailSender (org.springframework.mail.javamail.JavaMailSender)5 IOException (java.io.IOException)4 MessagingException (javax.mail.MessagingException)4 AbstractMolgenisSpringTest (org.molgenis.data.AbstractMolgenisSpringTest)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 MailSendException (org.springframework.mail.MailSendException)4 InternetAddress (jakarta.mail.internet.InternetAddress)3 MimeMessage (jakarta.mail.internet.MimeMessage)3 Date (java.util.Date)3 RunAsSystem (org.molgenis.security.core.runas.RunAsSystem)3 MolgenisUserException (org.molgenis.security.user.MolgenisUserException)3 JavaMailSenderImpl (org.springframework.mail.javamail.JavaMailSenderImpl)3 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)2 User (fr.codechill.spring.model.User)2