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

未来做那个网站能致富网站建设培训 ppt

未来做那个网站能致富,网站建设培训 ppt,wordpress中文杂志主题,保定百度seo排名📑前言 本文主要是【SpringBoot】——SpringBoot项目发送邮件的文章,如果有什么需要改进的地方还请大佬指出⛺️ 🎬作者简介:大家好,我是听风与他🥇 ☁️博客首页:CSDN主页听风与他 &#x1f3…

📑前言

本文主要是【SpringBoot】——SpringBoot项目发送邮件的文章,如果有什么需要改进的地方还请大佬指出⛺️

🎬作者简介:大家好,我是听风与他🥇
☁️博客首页:CSDN主页听风与他
🌄每日一句:狠狠沉淀,顶峰相见

目录

    • 📑前言
  • SpringBoot项目发送邮件
    • springboot整合mail发送邮件
    • 1.在pom.xml中导入邮件发送依赖
    • 2.配置yml文件中mail的信息
    • 3.编写邮件发送类EmailSending
    • 4.编写测试类EmailSendApplicationTests
    • 📑文章末尾

SpringBoot项目发送邮件

springboot整合mail发送邮件

1.在pom.xml中导入邮件发送依赖

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

2.配置yml文件中mail的信息

  mail:host: smtp.163.com #邮箱采用的是网易邮箱,也可以更换其他的邮箱username: 15671190765@163.compassword: xxxx  #配置邮箱的snmp验证信息

3.编写邮件发送类EmailSending

package com.emailsend.listener;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.Component;import java.util.Random;@Component
public class EmailSending {@AutowiredJavaMailSender sender;@Value("${spring.mail.username}")String username;private SimpleMailMessage createMessage(String title, String content, String email){SimpleMailMessage message = new SimpleMailMessage();message.setSubject(title);  //主题message.setText(content);   //内容message.setTo(email);       //发送目标邮箱message.setFrom(username);  //源发送邮箱return message;}public void sendMailMessage(String email){Random random = new Random();int code = random.nextInt(899999)+100000;SimpleMailMessage  message= this.createMessage("欢迎注册我们的网站","您的验证码为"+(code)+",有效时间三分钟,为了保障您的安全,请勿向他人泄露验证码信息。",email);if (message == null) return;sender.send(message);}
}

4.编写测试类EmailSendApplicationTests

package com.emailsend;import com.emailsend.listener.EmailSending;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;@SpringBootTest
class EmailSendApplicationTests {@Autowiredprivate EmailSending emailSending;@Testvoid contextLoads() {emailSending.sendMailMessage("2482893650@qq.com");}}

📑文章末尾

在这里插入图片描述

http://www.yayakq.cn/news/278648/

相关文章:

  • 南昌做公司网站wordpress加图片不显示
  • 什么不属于网站推广软件怎么在外管局的网站做延期
  • 免费高清视频素材网站企业网站建设目的意义
  • 青岛网站建设企业沧州讯呗网络科技有限公司
  • wordpress教材安徽seo推广公司
  • 南京网站优化技术百度搜索引擎网址格式
  • 网站运营意义百度推广效果怎样一天费用
  • 护肤网站的功能设计陕西电商网站建设
  • 行业门户网站是什么如何做自己的业务网站
  • 外网访问不了内网建设的网站驻马店高端网站建设
  • 广州建站公司网站电商网站建设分析
  • 做动态文字的网站WordPress无法提交评论
  • 网站开发用哪个软件好北京二次感染最新消息
  • 昆明汽车建站网站模板科技有限公司的经营范围
  • 垣曲做网站怎么做网站图片链接
  • 门户网站的意义深圳最乱最穷的地方
  • 雅虎做网站推广自己做文字壁纸的网站
  • 网站的最近浏览 怎么做公司注册网上核名app
  • 个人做网站开发网站设计网页主页介绍
  • 安徽网站设计方案从化网站制作
  • 我做外贸要开国际网站吗商城网站制作
  • 做手机网站哪家好长沙公司建设网站
  • 网站建设 中关村广州软件开发工资怎么样
  • 网站 建设文档我要在58上面做网站
  • 榆林网站建设公司网络营销典型企业
  • 招聘 负责网站开发毕业设计代做网站 知乎
  • 临汾万词霸屏网站建设免费咨询网站超市源码哪个好
  • 做排行网站上海市建设安装协会网站
  • 公司网站建设总结枣庄做网站公司
  • 公司网站简介为什么wordpress 打开