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

手机网站视频怎么下载培训学校加盟费用

手机网站视频怎么下载,培训学校加盟费用,wordpress 获取文章图片,zhon中国建设会计学会网站准备工作 开启SMTP服务 前往你的邮箱网站,以网易邮箱为例,打开网易邮箱地址,登录你的邮箱,进入邮箱管理后台界面。点击“设置”》》“POP3/SMTP/IMAP”后,点击开启SMTP服务即可。 技术实现 Spring Boot 发送邮件验证…

准备工作

开启SMTP服务

前往你的邮箱网站,以网易邮箱为例,打开网易邮箱地址,登录你的邮箱,进入邮箱管理后台界面。点击“设置”》》“POP3/SMTP/IMAP”后,点击开启SMTP服务即可。

技术实现


Spring Boot 发送邮件验证码的功能,主要用到了spring-boot-starter-mail工具包实现邮件的发送功能,利用junit-vintage-engine工具包实现了html邮件模板功能,利用easy-captcha工具包生成随机验证码 的功能!

引入依赖

     <!--引入mail依赖--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-mail</artifactId></dependency><!--mail模板--><dependency><groupId>org.junit.vintage</groupId><artifactId>junit-vintage-engine</artifactId><scope>test</scope><exclusions><exclusion><groupId>org.hamcrest</groupId><artifactId>hamcrest-core</artifactId></exclusion></exclusions></dependency><!--验证码--><dependency><groupId>com.github.whvcse</groupId><artifactId>easy-captcha</artifactId><version>1.6.2</version></dependency>

相关配置

然后再spring的配置文件中,设置mail相关配置:

spring:mail:host: smtp.yeah.comusername: 你的邮箱password: 邮箱授权码default-encoding: UTF-8protocol: smtpproperties:mail:smtp:auth: true # 启用SMTP认证starttls:enabled: true # 启用SMTP认证required: true # 必须采用加密链接

代码实现

创建一个MailService类,实现邮件发送的功能,代码如下:

import com.tarzan.nav.modules.admin.service.sys.SysConfigService;
import com.tarzan.nav.utils.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.antlr.stringtemplate.StringTemplate;
import org.antlr.stringtemplate.StringTemplateGroup;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;import javax.annotation.Resource;
import javax.mail.MessagingException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeUtility;
import java.io.UnsupportedEncodingException;
import java.util.Objects;/*** @author lsyong*/
@Component("mailService")
@Slf4j
public class MailService {private static final StringTemplateGroup templateGroup;@Resourceprivate  SysConfigService sysConfigService;static{String classpath = Objects.requireNonNull(MailService.class.getClassLoader().getResource("")).getPath();templateGroup = new StringTemplateGroup("mailTemplates", classpath + "/mailTemplates");}public static String IMG_BASE_URL;public static String ACTIVATE_CONTEXT="http:";public static String RESET_PWD_CONTEXT;@Value("${spring.mail.username}")private String username;@Resourceprivate JavaMailSender mailSender;private void sendMail(String to, String subject, String body) {MimeMessage mail = mailSender.createMimeMessage();	try {MimeMessageHelper helper = new MimeMessageHelper(mail, true, "utf-8");helper.setFrom(new InternetAddress(MimeUtility.encodeText(sysConfigService.getSiteName())+"<"+username+">").toString());helper.setTo(to);helper.setSubject(subject);helper.setText(body, true);helper.setSentDate(DateUtil.now());mailSender.send(mail);} catch (MessagingException|UnsupportedEncodingException e) {log.error(e.getMessage());}}/*** send activation mail to* @param to,key*/public void sendAccountActivationEmail(String to, String key){StringTemplate activation_temp = templateGroup.getInstanceOf("activation");activation_temp.setAttribute("img_base_url", IMG_BASE_URL);activation_temp.setAttribute("email", to);activation_temp.setAttribute("href", ACTIVATE_CONTEXT+key+"?email="+to);activation_temp.setAttribute("link", ACTIVATE_CONTEXT+key+"?email="+to);sendMail(to, sysConfigService.getSiteName()+"账户激活", activation_temp.toString());}@Asyncpublic void sendEmailCode(String to, String code){StringTemplate activation_temp = templateGroup.getInstanceOf("verificationCode");activation_temp.setAttribute("img_base_url", IMG_BASE_URL);activation_temp.setAttribute("email", to);activation_temp.setAttribute("code", code);sendMail(to, sysConfigService.getSiteName()+"邮箱验证码", activation_temp.toString());}/*** send change password link to* @param to,key*/public void sendResetPwdEmail(String to, String key){StringTemplate activation_temp = templateGroup.getInstanceOf("resetpwd");activation_temp.setAttribute("img_base_url", IMG_BASE_URL);activation_temp.setAttribute("href", RESET_PWD_CONTEXT+"?key="+key+"&email="+to);activation_temp.setAttribute("link", RESET_PWD_CONTEXT+"?key="+key+"&email="+to);sendMail(to, sysConfigService.getSiteName()+"账户密码重置", activation_temp.toString());}
}

http://www.dinnco.com/news/66518.html

相关文章:

  • wordpress 插件 教程视频教程电池优化大师下载
  • 网站建设应该注意哪些原则百度官方app免费下载
  • 群晖 做网站 Javaseo搜索优化工程师招聘
  • 网站做淘宝推广收入windows优化大师的功能
  • 网站建设相关基础实验总结seo网络推广什么意思
  • 汕头市政府济南网站推广优化
  • 技术支持 如皋网站建设宁波网站制作优化服务
  • wordpress 模版标签宝鸡seo外包公司
  • 温州做网站的企业seo做的好的网站
  • 厦门靠谱建网站公司商业推广软文范例
  • 深圳产品外观设计公司内部搜索引擎优化
  • java jsp 如何做门户网站宁波seo关键词
  • 网站大全下载软件安装百度账号批发网
  • 网站怎么适配移动端石家庄房价
  • 升级网页临沂百度seo
  • 网站备案管谁要幕布搜索引擎的作用
  • funpinpin建站平台优化大师的优化项目有哪7个
  • 帝国管理系统导入新的模板怎么建网站?搜索引擎优化英文简称为
  • h5制作网站开发阳江网站建设
  • 中国建设银行网站快速查询南宁seo排名收费
  • 网络营销品牌案例分析抖音seo培训
  • 专业招牌制作价格海口seo计费
  • 分类 网站模板外包
  • 网站宣传视频地推的60种方法
  • 用ul做的网站为何浮动不上去焦作seo公司
  • 网站做树状结构有什么作用关键词排名的工具
  • 没有做老千的斗牛网站6东莞哪种网站推广好
  • 网站建立风格淘客推广
  • 做物流的可以在那些网站找客户端小广告图片
  • 网上帮做一些小事赚零花钱的网站企业网站制作价格