Guest User

Untitled

a guest
Jan 28th, 2019
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. Application.yml
  2.  
  3. mail:
  4. host: smtp.gmail.com
  5. port: 587
  6. username:
  7. password:
  8. properties:
  9. mail:
  10. smtp:
  11. auth: true
  12. starttls:
  13. enable: true
  14.  
  15. MailService:
  16.  
  17. public class EmailServiceImpl implements EmailService {
  18.  
  19. @Autowired
  20. private JavaMailSender mailSender;
  21.  
  22. /**
  23. * Send email.
  24. *
  25. * @param to the to
  26. * @param subject the subject
  27. * @param text the text
  28. */
  29. @Override
  30. public void sendEmail(String to, String subject, String text) {
  31.  
  32. try {
  33. SimpleMailMessage message = new SimpleMailMessage();
  34. message.setTo(to);
  35. message.setSubject(subject);
  36. message.setText(text);
  37.  
  38. mailSender.send(message);
  39. } catch (MailException e) {
  40. log.info("Mail Exception {}", e);
  41. }
  42.  
  43.  
  44. }
Add Comment
Please, Sign In to add comment