package com.example.demo.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Date;
@Service
@EnableScheduling // 2.开启定时任务
public class IndexService{
@Autowired
JavaMailSenderImpl mailSender; //引入邮件发送
@Scheduled(cron = "0/5 * * * * ?") //每隔5秒发送一次邮件
public void hello(){
SimpleMailMessage mailMessage
java定时发送邮件springBoot
最新推荐文章于 2023-06-26 11:00:58 发布