package com.tzy.common.utils.email;

import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 邮件发送器
 */
@Service
public class EmailService {

    @Resource
    private JavaMailSender mailSender;

    @Async
    public void sendSimpleMail(String mailAddr, String subject, String text) {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setTo(mailAddr);
        message.setSubject(subject);
        message.setText(text);
        message.setFrom("yu@shpydzswyxgs.wecom.work");
        mailSender.send(message);
    }
}