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

天津网站建设营销aws 虚机wordpress教程

天津网站建设营销,aws 虚机wordpress教程,wordpress脚注,网络推广龙岗比较好的准备工作 开启SMTP服务 前往你的邮箱网站#xff0c;以网易邮箱为例#xff0c;打开网易邮箱地址#xff0c;登录你的邮箱#xff0c;进入邮箱管理后台界面。点击“设置”》》“POP3/SMTP/IMAP”后#xff0c;点击开启SMTP服务即可。 技术实现 Spring Boot 发送邮件验证…准备工作 开启SMTP服务 前往你的邮箱网站以网易邮箱为例打开网易邮箱地址登录你的邮箱进入邮箱管理后台界面。点击“设置”》》“POP3/SMTP/IMAP”后点击开启SMTP服务即可。 技术实现 Spring Boot 发送邮件验证码的功能主要用到了spring-boot-starter-mail工具包实现邮件的发送功能利用junit-vintage-engine工具包实现了html邮件模板功能利用easy-captcha工具包生成随机验证码 的功能 引入依赖 !--引入mail依赖--dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-mail/artifactId/dependency!--mail模板--dependencygroupIdorg.junit.vintage/groupIdartifactIdjunit-vintage-engine/artifactIdscopetest/scopeexclusionsexclusiongroupIdorg.hamcrest/groupIdartifactIdhamcrest-core/artifactId/exclusion/exclusions/dependency!--验证码--dependencygroupIdcom.github.whvcse/groupIdartifactIdeasy-captcha/artifactIdversion1.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_CONTEXThttp:;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_CONTEXTkey?emailto);activation_temp.setAttribute(link, ACTIVATE_CONTEXTkey?emailto);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?keykeyemailto);activation_temp.setAttribute(link, RESET_PWD_CONTEXT?keykeyemailto);sendMail(to, sysConfigService.getSiteName()账户密码重置, activation_temp.toString());} }
http://www.zqtcl.cn/news/418320/

相关文章:

  • 国际学校网站如何建设wordpress登入可见
  • 如何做好网站内链网站开发平台开发
  • 安徽省建设厅网站怎么进不去2022年国内重要新闻
  • 河北建设机械协会网站wordpress怎么做两个语言网站
  • 美容网站模版在线动画手机网站模板
  • jsp做的婚恋网站在谷歌上做英文网站
  • 北京教育学会网站建设昆明seo公司网站
  • 免费域名试用注册网站google搜索关键词热度
  • 温州建设小学网站高中资料网站免费
  • 室内设计网站官网大全电子商务网站后台核心管理
  • 网站建设报价图片欣赏福州网站建设报价
  • 网站推广基本方法是文创产品设计稿
  • 厦门网站制作公司推荐作文网投稿网站
  • 网站开发过什么软件杭州cms建站模板下载
  • 做中东服装有什么网站谁能给我个网址
  • 深圳网站建设公司服务平台河北省建设银行网站首页
  • 新密网站网页版微信小程序在哪
  • 长春建一个网站大概要多少钱微信公众号开店流程
  • 网站运营实例django 微信小程序开发教程
  • wordpress 搭网站郑州网站建设华久
  • 网站建设图片尺寸专门做音乐的网站
  • 株洲做网站外贸推广产品
  • 枫叶的网站建设博客企业网站样板制作
  • 织梦网站文章相互调用百度下载老版本
  • pc网站的优势网站建设款属不属于无形资产
  • 网站建设数据安全分析网络全案推广
  • 网站建设哪家好就推 鹏博资讯手机自助建网站
  • 沈阳网站制作招聘网长治网站建设电话
  • 承德网站设计公司余姚做百度网站
  • 阿里云购买网站空间做网站怎么插音乐循环