Search in sources :

Example 6 with SimpleMailMessage

use of org.springframework.mail.SimpleMailMessage in project Internet-Software-Architectures by zivko11.

the class Mailing method sendRegistration.

public void sendRegistration(String mail, String token) {
    String link = "localhost:8080/cinema-theatre/confirmatin.html?token=";
    String subject = "Registration Confirmation";
    String confirmationUrl = link + token;
    String message = "Confirm your registration on this link: ";
    SimpleMailMessage email = new SimpleMailMessage();
    email.setTo(mail);
    email.setSubject(subject);
    email.setText(message + confirmationUrl);
    mailSender.send(email);
}
Also used : SimpleMailMessage(org.springframework.mail.SimpleMailMessage)

Example 7 with SimpleMailMessage

use of org.springframework.mail.SimpleMailMessage in project uhgroupings by uhawaii-system-its-ti-iam.

the class EmailService method send.

public void send(Feedback feedback) {
    if (isEnabled) {
        logger.info("\n/********************************************************************************************/" + "\n\nSending email!\n\n" + "/********************************************************************************************/\n");
        SimpleMailMessage msg = new SimpleMailMessage();
        msg.setTo(to);
        msg.setFrom(from);
        String text = "";
        String header = "Feedback Type: " + feedback.getType();
        text += "Feedback reported by " + feedback.getName() + " using email " + feedback.getEmail() + "\n\n";
        text += "Feedback: " + feedback.getMessage();
        text += "Stacktrace: " + feedback.getExceptionError();
        msg.setText(text);
        msg.setSubject(header);
        try {
            javaMailSender.send(msg);
        } catch (MailException ex) {
            logger.error("Error", ex);
        }
    }
}
Also used : SimpleMailMessage(org.springframework.mail.SimpleMailMessage) MailException(org.springframework.mail.MailException)

Example 8 with SimpleMailMessage

use of org.springframework.mail.SimpleMailMessage in project code-chill by CodeChillAlluna.

the class UserController method processForgotPasswordForm.

// Process form submission from forgotPassword page
@PostMapping(value = "/user/forgottenpassword")
public ResponseEntity<?> processForgotPasswordForm(@RequestBody String email) {
    User user = urepo.findByEmail(email);
    HttpHeaders responseHeaders = new HttpHeaders();
    if (user != null) {
        user.setLastPasswordResetDate(new Date());
        user.setTokenPassword(UUID.randomUUID().toString());
        user = urepo.save(user);
        SimpleMailMessage passwordResetEmail = new SimpleMailMessage();
        passwordResetEmail.setFrom(SENDFROM);
        passwordResetEmail.setTo(user.getEmail());
        passwordResetEmail.setSubject("Password Reset Request");
        passwordResetEmail.setText("Reset link:\n" + BASE_URL + "/reset/" + user.getTokenPassword());
        mailSender.send(passwordResetEmail);
        return ResponseEntity.ok().headers(responseHeaders).body(user);
    }
    return ResponseEntity.badRequest().headers(responseHeaders).body(user);
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) User(fr.codechill.spring.model.User) SimpleMailMessage(org.springframework.mail.SimpleMailMessage) Date(java.util.Date) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 9 with SimpleMailMessage

use of org.springframework.mail.SimpleMailMessage in project code-chill by CodeChillAlluna.

the class UserController method updateUserEmail.

// method sending a mail to a new user email
public boolean updateUserEmail(String email) {
    if (!email.equals("")) {
        SimpleMailMessage updateEmail = new SimpleMailMessage();
        updateEmail.setFrom(SENDFROM);
        updateEmail.setTo(email);
        updateEmail.setSubject("Email adresse change");
        updateEmail.setText("Your new email adress has been saved by our services");
        mailSender.send(updateEmail);
        return true;
    }
    return false;
}
Also used : SimpleMailMessage(org.springframework.mail.SimpleMailMessage)

Example 10 with SimpleMailMessage

use of org.springframework.mail.SimpleMailMessage in project webofneeds by researchstudio-sat.

the class WonMailSender method sendTextMessage.

public void sendTextMessage(String toEmail, String subject, String text) {
    SimpleMailMessage msg = new SimpleMailMessage(this.templateMessage);
    msg.setSubject(subject);
    msg.setTo(toEmail);
    msg.setText(text);
    try {
        mailSender.send(msg);
    } catch (MailException ex) {
        logger.warn(ex.getMessage());
    }
}
Also used : SimpleMailMessage(org.springframework.mail.SimpleMailMessage) MailException(org.springframework.mail.MailException)

Aggregations

SimpleMailMessage (org.springframework.mail.SimpleMailMessage)103 MailException (org.springframework.mail.MailException)16 Test (org.junit.Test)12 Test (org.testng.annotations.Test)7 Test (org.junit.jupiter.api.Test)6 User (org.molgenis.data.security.auth.User)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 InternetAddress (jakarta.mail.internet.InternetAddress)3 MimeMessage (jakarta.mail.internet.MimeMessage)3 Date (java.util.Date)3 MimeMessage (javax.mail.internet.MimeMessage)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 User (gemma.gsec.model.User)2