spring.mail.port=465
spring.mail.username=970959041@qq.com
spring.mail.password=xfuupxjimcpfbbdf
spring.mail.properties.mail.smtp.ssl.enable=true
spring.mail.properties.mail.smtp.auth=true
#spring.mail.properties.mail.smtp.starttls.enable=false
#spring.mail.properties.mail.smtp.starttls.required=false
@Component
public class EmailSender {
@Autowired
private JavaMailSender emailSender;
public void sendEmailToRecepient() throws MessagingException {
MimeMessage mimeMessage = emailSender.createMimeMessage();
MimeMessageHelper message = new MimeMessageHelper(mimeMessage, true, "UTF-8");
message.setFrom("xxxx@qq.com");
message.setTo("yyyy@qq.com");
message.setSubject("this is a test");
message.setText("Good luck", true);
emailSender.send(mimeMessage);
}
}