SHARE
TWEET

Untitled

a guest Jun 18th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package ru.dev.messanger.service;
  2.  
  3. import org.springframework.beans.factory.annotation.Autowired;
  4. import org.springframework.beans.factory.annotation.Value;
  5. import org.springframework.mail.SimpleMailMessage;
  6. import org.springframework.mail.javamail.JavaMailSender;
  7. import org.springframework.stereotype.Service;
  8.  
  9. @Service
  10. public class MailSender {
  11.     @Autowired
  12.     private JavaMailSender mailSender;
  13.  
  14.     @Value("${spring.mail.username}")
  15.     private String username;
  16.  
  17.     public void send(String emailTo, String subject, String message) {
  18.         SimpleMailMessage mailMessage = new SimpleMailMessage();
  19.  
  20.         mailMessage.setFrom(username);
  21.         mailMessage.setTo(emailTo);
  22.         mailMessage.setSubject(subject);
  23.         mailMessage.setText(message);
  24.  
  25.         mailSender.send(mailMessage);
  26.     }
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top