39 lines
1.0 KiB
Java
Executable File
39 lines
1.0 KiB
Java
Executable File
package com.plannaplan.services;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.mail.SimpleMailMessage;
|
|
import org.springframework.mail.javamail.JavaMailSender;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
/**
|
|
* Service to send emails
|
|
*/
|
|
@Service
|
|
public class EmailService {
|
|
|
|
@Autowired
|
|
private JavaMailSender emailSender;
|
|
|
|
@Value("${plannaplan.email}")
|
|
private String appEmail;
|
|
|
|
public EmailService() {
|
|
}
|
|
|
|
/**
|
|
* send simple text email
|
|
*
|
|
* @param destination destitnaion mail
|
|
* @param message text to be send
|
|
*/
|
|
public void sendMail(String destination, String message) {
|
|
SimpleMailMessage mailMessage = new SimpleMailMessage();
|
|
mailMessage.setFrom(appEmail);
|
|
mailMessage.setTo(destination);
|
|
mailMessage.setSubject("[Plan na plan] INFO");
|
|
mailMessage.setText(message);
|
|
emailSender.send(mailMessage);
|
|
}
|
|
}
|