Search in sources :

Example 96 with SimpleMailMessage

use of org.springframework.mail.SimpleMailMessage in project spring-rest-security-boilerplate by springboilerplate.

the class Mailer method resendVerificationToken.

public void resendVerificationToken(AppUser user, VerificationToken token) {
    final SimpleMailMessage email = constructResendVerificationTokenEmail(user, token);
    System.out.println("New token is : " + token.getToken());
    if (SEND_MAIL == true)
        mailSender.send(email);
    System.out.println(email);
}
Also used : SimpleMailMessage(org.springframework.mail.SimpleMailMessage)

Example 97 with SimpleMailMessage

use of org.springframework.mail.SimpleMailMessage in project spring-rest-security-boilerplate by springboilerplate.

the class Mailer method registrationTokenEmail.

public void registrationTokenEmail(OnRegistrationCompleteEvent event, AppUser user, String token) {
    final SimpleMailMessage email = constructRegistrationEmailMessage(event, user, token);
    if (SEND_MAIL == true)
        mailSender.send(email);
    System.out.println(email);
}
Also used : SimpleMailMessage(org.springframework.mail.SimpleMailMessage)

Example 98 with SimpleMailMessage

use of org.springframework.mail.SimpleMailMessage in project ngtesting-platform by aaronchen2k.

the class SystemConfig method simpleMailMessage.

@Bean
public SimpleMailMessage simpleMailMessage() {
    SimpleMailMessage mailMessage = new SimpleMailMessage();
    mailMessage.setFrom(mailUserName);
    mailMessage.setSubject("来自ngtesting.com的邮件");
    return mailMessage;
}
Also used : SimpleMailMessage(org.springframework.mail.SimpleMailMessage) Bean(org.springframework.context.annotation.Bean)

Example 99 with SimpleMailMessage

use of org.springframework.mail.SimpleMailMessage in project tutorials-java by Artister.

the class ApplicationTests method sendSimpleMail.

@Test
public void sendSimpleMail() throws Exception {
    SimpleMailMessage message = new SimpleMailMessage();
    message.setFrom(from);
    message.setTo(from);
    message.setSubject("主题:简单邮件");
    message.setText("测试邮件内容");
    mailSender.send(message);
}
Also used : SimpleMailMessage(org.springframework.mail.SimpleMailMessage) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 100 with SimpleMailMessage

use of org.springframework.mail.SimpleMailMessage in project onebusaway-application-modules by camsys.

the class ForgotPasswordAction method execute.

@Override
public String execute() {
    // Don't check permissions.
    SimpleMailMessage msg = getMessage();
    try {
        _mailSender.send(msg);
        _log.info("Sent email.");
    } catch (Exception e) {
        _log.error("Could not send email: " + e.getMessage());
        throw new RuntimeException("Unable to send email.");
    }
    return SUCCESS;
}
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