Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Application.yml
- mail:
- host: smtp.gmail.com
- port: 587
- username:
- password:
- properties:
- mail:
- smtp:
- auth: true
- starttls:
- enable: true
- MailService:
- public class EmailServiceImpl implements EmailService {
- @Autowired
- private JavaMailSender mailSender;
- /**
- * Send email.
- *
- * @param to the to
- * @param subject the subject
- * @param text the text
- */
- @Override
- public void sendEmail(String to, String subject, String text) {
- try {
- SimpleMailMessage message = new SimpleMailMessage();
- message.setTo(to);
- message.setSubject(subject);
- message.setText(text);
- mailSender.send(message);
- } catch (MailException e) {
- log.info("Mail Exception {}", e);
- }
- }
Add Comment
Please, Sign In to add comment