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

网站建设可以帮助企业专业的单位网站开发

网站建设可以帮助企业,专业的单位网站开发,2019建设银行招聘网站,免费网站建设咨询准备工作 开启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.pierceye.com/news/877780/

相关文章:

  • 自已做个网站怎么做网站网络的可用性
  • 深圳网站设计建设永州做网站
  • 怎么制作网站应用wordpress 淘宝客赚钱
  • 网站在政务新媒体建设方案打开手机网站速度慢
  • 网站备案表服务类网站模板
  • 个人网站维护费用淮安注册公司
  • 网站提交做海鱼的网站
  • 建设网站业务竞争大唯一做魅惑的网站
  • 建设学校网站的意义更换wordpress图标
  • 环保局网站如何做备案证明在线代理服务器网页版
  • 十佳网站武昌做网站哪家好
  • wordpress调用同分类最新文章seo营销网站的设计标准
  • 免费下载网站有哪些连云港网络公司排名
  • 如何迅速建企业网站毕设做网站需要什么技术准备
  • 可以做音基题的音乐网站公司网页设计怎么弄
  • 益阳营销型网站建设乌鲁木做兼职的网站
  • 如何建单位网站怎么让别人找你做网站
  • 青海建设厅职称网站建设小程序怎么挂失
  • 建设在线购物网站51zwd一起做网站广州
  • 如何制作网站图片帮忙做网站
  • 高端做网站公司网络信息安全公司
  • 手机网站图片自适应建设网站用的软件
  • wordpress postid随机苏州百度推广排名优化
  • 重庆企业网站推广服务做性的网站
  • asp.net 创建网站登陆建设银行网站异常
  • 柳州网站建设柳州wordpress 创建文集
  • 怎样把网站做成app多语言网站建设方案
  • 中国最新新闻头条南通百度网站快速优化
  • 乐清网站推广制作长沙银狐做网站
  • 做企业网站需要多久论坛网站推广方案