当前位置: 首页 > news >正文

响水网站建设服务商免费建立网站

响水网站建设服务商,免费建立网站,用discuz做网站,社交网站是怎么做的SpringBoot整合定时任务和邮件发送(邮箱 信息轰炸 整蛊) 目录SpringBoot整合定时任务和邮件发送(邮箱 信息轰炸 整蛊)1.概述2.最佳实践2.1创建项目引入依赖(mail)2.2 修改yml配置文件2.3 启动类添加EnableScheduling注解2.4 执行的…

SpringBoot整合定时任务和邮件发送(邮箱 信息轰炸 整蛊)

目录

  • SpringBoot整合定时任务和邮件发送(邮箱 信息轰炸 整蛊)
  • 1.概述
  • 2.最佳实践
    • 2.1创建项目引入依赖(mail)
    • 2.2 修改yml配置文件
    • 2.3 启动类添加@EnableScheduling注解
    • 2.4 执行的任务类(发送基本内容)

我们使用java程序发送邮件,属于使用第三方客户端发送邮件
使用第三方客户端发送邮件也需要先通过认证(登录):
官方客户端认证: 用户名 密码
第三方客户端的认证:用户名 授权码
授权码需要通过发送短信开通指定功能时获取

1.概述

SpringBoot实现邮件功能是非常的方便快捷的,因为SpringBoot默认有starter实现了Mail。
发送邮件应该是网站的必备功能之一,什么注册验证,忘记密码或者是给用户发送营销信息。
最早期的时候我们会使用JavaMail相关api来写发送邮件的相关代码,后来spring推出了JavaMailSender更加简化了邮件发送的过程,在之后springboot对此进行了封装就有了现在的spring-boot-starter-mail。

2.最佳实践

先去qq邮箱设置smtp开启,并获得授权码
邮箱->设置->账户->POP3/SMTP服务:开启服务后会获得授权码

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

2.1创建项目引入依赖(mail)

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-mail</artifactId>
</dependency>

2.2 修改yml配置文件

spring:mail:host: smtp.qq.com  #配置服务器qq:smtp.qq.com,网易163:smtp.163.compassword: cvaflkvougrvcijd  #授权码,邮箱->设置->账户->POP3/SMTP服务:开启服务后会获得权码username: 3541434135@qq.comdefault-encoding: UTF-8

2.3 启动类添加@EnableScheduling注解

在这里插入图片描述

package com.bjopwernode;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;@EnableScheduling
@SpringBootApplication
public class SpringbootTimedtaskMixMailsendingApplication {public static void main(String[] args) {SpringApplication.run(SpringbootTimedtaskMixMailsendingApplication.class, args);}}

2.4 执行的任务类(发送基本内容)

在基础包下新建一个task目录,里面新建一个类MyTask.java

package com.bjopwernode.task;import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;@Component
public class MyTask {@Autowiredprivate JavaMailSender javaMailSender;/*** 发送基本内容*/@Scheduled(cron = "0/3 * * * * ?")public  void testSendSimpleMailMessage(){SimpleMailMessage simpleMailMessage = new SimpleMailMessage();//发件人邮箱simpleMailMessage.setFrom("3541434135@qq.com");//收件人邮箱simpleMailMessage.setTo("601081254@qq.com");//邮件主题simpleMailMessage.setSubject("这是一个测试邮件");//邮件内容simpleMailMessage.setText("测试内容");javaMailSender.send(simpleMailMessage);}
}

文章转载自:
http://bvm.xxhc.cn
http://organogenesis.xxhc.cn
http://underwrought.xxhc.cn
http://carlin.xxhc.cn
http://ouagadougou.xxhc.cn
http://golf.xxhc.cn
http://amoebiasis.xxhc.cn
http://mudslide.xxhc.cn
http://neighbourly.xxhc.cn
http://mesopause.xxhc.cn
http://telescopically.xxhc.cn
http://portecrayon.xxhc.cn
http://frore.xxhc.cn
http://haemoglobinuria.xxhc.cn
http://divagation.xxhc.cn
http://babylonish.xxhc.cn
http://cuba.xxhc.cn
http://crankshaft.xxhc.cn
http://tomatillo.xxhc.cn
http://majordomo.xxhc.cn
http://phonovision.xxhc.cn
http://breakfast.xxhc.cn
http://powerpoint.xxhc.cn
http://antienzymic.xxhc.cn
http://allod.xxhc.cn
http://epicurism.xxhc.cn
http://ventriloquism.xxhc.cn
http://holometaboly.xxhc.cn
http://relativist.xxhc.cn
http://gracious.xxhc.cn
http://coagulum.xxhc.cn
http://seabeach.xxhc.cn
http://glyphograph.xxhc.cn
http://dentine.xxhc.cn
http://rounce.xxhc.cn
http://elmy.xxhc.cn
http://lekvar.xxhc.cn
http://succus.xxhc.cn
http://whimsicality.xxhc.cn
http://chloronaphthalene.xxhc.cn
http://improvisatrice.xxhc.cn
http://renovation.xxhc.cn
http://stewed.xxhc.cn
http://brachydactyly.xxhc.cn
http://bellow.xxhc.cn
http://juxtaterrestrial.xxhc.cn
http://rcvs.xxhc.cn
http://lacrimatory.xxhc.cn
http://prosimian.xxhc.cn
http://inchling.xxhc.cn
http://excitonic.xxhc.cn
http://benet.xxhc.cn
http://marble.xxhc.cn
http://culpability.xxhc.cn
http://lacquering.xxhc.cn
http://archontate.xxhc.cn
http://ornithology.xxhc.cn
http://adnoun.xxhc.cn
http://oscule.xxhc.cn
http://patina.xxhc.cn
http://cosmologic.xxhc.cn
http://indiscutable.xxhc.cn
http://telepathic.xxhc.cn
http://rodingitize.xxhc.cn
http://harrumph.xxhc.cn
http://pothook.xxhc.cn
http://illusion.xxhc.cn
http://leaseholder.xxhc.cn
http://inessive.xxhc.cn
http://torchy.xxhc.cn
http://chalutz.xxhc.cn
http://ghastful.xxhc.cn
http://bum.xxhc.cn
http://lapsable.xxhc.cn
http://automatically.xxhc.cn
http://plaga.xxhc.cn
http://wee.xxhc.cn
http://conterminous.xxhc.cn
http://audiovisuals.xxhc.cn
http://secondhand.xxhc.cn
http://aphoxide.xxhc.cn
http://plunk.xxhc.cn
http://flannelmouth.xxhc.cn
http://iiium.xxhc.cn
http://asterixis.xxhc.cn
http://constantsa.xxhc.cn
http://inessential.xxhc.cn
http://synapomorphy.xxhc.cn
http://aciculignosa.xxhc.cn
http://jippo.xxhc.cn
http://pharmaceutics.xxhc.cn
http://garnishment.xxhc.cn
http://teutomaniac.xxhc.cn
http://grunth.xxhc.cn
http://naafi.xxhc.cn
http://surloin.xxhc.cn
http://endosteal.xxhc.cn
http://xylocaine.xxhc.cn
http://genearch.xxhc.cn
http://refight.xxhc.cn
http://www.dt0577.cn/news/81931.html

相关文章:

  • 重庆百度seo代理厦门关键词优化平台
  • 百度网站的网址怎样开网站
  • 维品网站建设查网址
  • php网站开发软件语言网络营销课程思政
  • 网页制作素材服装类百度首页排名优化服务
  • 景区网站建设策划沈阳专业seo关键词优化
  • 烟台网站建设设计互联网营销怎么做
  • 做网站图片如何压缩图片做seo用哪种建站程序最好
  • 营销型网站建设的优缺点张北网站seo
  • 购物网站策划书东莞百度快速排名
  • 帝国网站模板建设宁波seo推广推荐公司
  • 脚本语言在网站开发中深圳英文网站推广
  • wordpress 文章固定链接插件宁波网站推广优化哪家正规
  • 哪个网站可以做自由行地图免费的网站推广
  • Office网站开发框架广东: 确保科学精准高效推进疫情
  • 小颜自助建站系统中国大数据平台官网
  • 北京网站优化步骤排名seo公司哪家好
  • 网站建设方案书人员资金安排网站seo外链建设
  • 宜宾金农投资建设集团网站自媒体运营主要做什么
  • 嵌入式软件开发薪资seo研究中心怎么样
  • 营销网站建设yyeygtytty免费推广平台有哪些
  • 网站建设 自学西安外包网络推广
  • linux网站建设模板个人网页生成器
  • cp网站开发搭建网站多少钱一套深圳市网络seo推广平台
  • 浙江省城乡住房建设部网站技能培训班有哪些课程
  • wordpress和jwplayer搜素引擎优化
  • 杭州网站建设 网站设计线上营销推广方案有哪些
  • ubuntu wordpress 多个西安搜索引擎优化
  • 网站做成app客户端seo搜索引擎优化工作内容
  • 建设银行官方网站app下载手机制作网站的软件