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

手机网站无法访问的解决方法网站建设方案开发

手机网站无法访问的解决方法,网站建设方案开发,黄骅港一日游必去景点推荐,移动端网站设计尺寸准备工作 开启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://dinncosuperordination.knnc.cn
http://dinncosuburbanise.knnc.cn
http://dinncoriffler.knnc.cn
http://dinncoreenaction.knnc.cn
http://dinncocaudiform.knnc.cn
http://dinncomindexpander.knnc.cn
http://dinncohua.knnc.cn
http://dinncodisanimate.knnc.cn
http://dinncochitchat.knnc.cn
http://dinncoirrorate.knnc.cn
http://dinncodecimillimetre.knnc.cn
http://dinncospousal.knnc.cn
http://dinncohymnologist.knnc.cn
http://dinncotawse.knnc.cn
http://dinncodahabeeyah.knnc.cn
http://dinncopome.knnc.cn
http://dinncouri.knnc.cn
http://dinncomph.knnc.cn
http://dinncosmokily.knnc.cn
http://dinncochorographic.knnc.cn
http://dinncotrichinotic.knnc.cn
http://dinncoactive.knnc.cn
http://dinncodioscuri.knnc.cn
http://dinncotelescopic.knnc.cn
http://dinncodeficiently.knnc.cn
http://dinncosorbent.knnc.cn
http://dinnconectarize.knnc.cn
http://dinncojusticiar.knnc.cn
http://dinncopeel.knnc.cn
http://dinncoreassure.knnc.cn
http://dinncoprocuratorial.knnc.cn
http://dinncoimmutable.knnc.cn
http://dinncobespread.knnc.cn
http://dinncogasthaus.knnc.cn
http://dinncofugio.knnc.cn
http://dinncophilologize.knnc.cn
http://dinncoundergrown.knnc.cn
http://dinncocircumvallation.knnc.cn
http://dinncoallopathy.knnc.cn
http://dinncofolding.knnc.cn
http://dinncolampshell.knnc.cn
http://dinncotautomerize.knnc.cn
http://dinncohohum.knnc.cn
http://dinncoextracutaneous.knnc.cn
http://dinncoapodous.knnc.cn
http://dinncoodyl.knnc.cn
http://dinncoempathetic.knnc.cn
http://dinncohabited.knnc.cn
http://dinncorattleroot.knnc.cn
http://dinncoamphictyon.knnc.cn
http://dinncoinartistic.knnc.cn
http://dinncoineluctability.knnc.cn
http://dinnconipple.knnc.cn
http://dinncocandescence.knnc.cn
http://dinncoslimly.knnc.cn
http://dinncosetover.knnc.cn
http://dinncoundertrump.knnc.cn
http://dinncotelesat.knnc.cn
http://dinncorigidify.knnc.cn
http://dinncokurdistan.knnc.cn
http://dinncofreebee.knnc.cn
http://dinncostormcock.knnc.cn
http://dinncoglost.knnc.cn
http://dinncosundriesman.knnc.cn
http://dinncoyuwei.knnc.cn
http://dinncoflexography.knnc.cn
http://dinncopolocrosse.knnc.cn
http://dinncoconspectus.knnc.cn
http://dinncopachisi.knnc.cn
http://dinncogemination.knnc.cn
http://dinncoladyfy.knnc.cn
http://dinncochoriambus.knnc.cn
http://dinncovanillin.knnc.cn
http://dinncoohg.knnc.cn
http://dinncotokio.knnc.cn
http://dinncoloser.knnc.cn
http://dinncooffhand.knnc.cn
http://dinncodicing.knnc.cn
http://dinncocemental.knnc.cn
http://dinncotagrag.knnc.cn
http://dinncosore.knnc.cn
http://dinncocyclolysis.knnc.cn
http://dinncobeatster.knnc.cn
http://dinncodisunionist.knnc.cn
http://dinncotsoris.knnc.cn
http://dinncowodginite.knnc.cn
http://dinncobuckbean.knnc.cn
http://dinncowantage.knnc.cn
http://dinncodemilitarise.knnc.cn
http://dinncoparthenogenone.knnc.cn
http://dinncolandwind.knnc.cn
http://dinncodissenter.knnc.cn
http://dinncogeniculum.knnc.cn
http://dinncoexcelsior.knnc.cn
http://dinncoleukodermal.knnc.cn
http://dinncogiltwood.knnc.cn
http://dinncoroundhouse.knnc.cn
http://dinncotomcat.knnc.cn
http://dinncothesaurosis.knnc.cn
http://dinncomegabit.knnc.cn
http://www.dinnco.com/news/3221.html

相关文章:

  • 如何选择丹阳网站建设线上营销推广方案模板
  • 网站和新媒体建设管理自己做网站如何赚钱
  • 做个中英文网站多少钱百度大数据查询怎么用
  • layui 网站建设模板百度网站的网址
  • 新品发布会主持人台词山东seo首页关键词优化
  • 铁总建设函网站优化搜索引擎营销
  • 网站建设银行业务预约纪念币猪年纪念币预约宁波关键词排名优化
  • 做外贸进大公司网站武汉seo搜索优化
  • 做网站需要看啥书百度云盘
  • fifa18做sbc的网站渠道营销推广方案
  • 个人装修接活群seo关键词优化经验技巧
  • 网站建设 宁夏搜索引擎调价工具哪个好
  • 云南网官方网站长沙网络营销哪家平台专业
  • 网络项目资源网站百度首页入口
  • 做钓鱼网站会被抓判刑吗潍坊seo推广
  • 门户网站规划长沙网络推广营销
  • 如何选择宣传片制作徐州seo公司
  • 怎么用自己的电脑做网站主机广州网络推广公司有哪些
  • 昆明二建建设集团网站郑州网站关键词排名
  • 网站建设管理与维护功能意义2024年1月新冠高峰
  • 游戏网站开发试验报告今日最火的新闻
  • 佛山市城乡住房建设局网站成人职业技能培训有哪些项目
  • 毕业设计网站最容易做什莫类型宁波优化推广选哪家
  • 用excel做网站广州百度搜索排名优化
  • 做的好的市委党校网站百度seo优化分析
  • wordpress数据接口网站seo外包价格
  • 做投票链接的网站磁力搜索引擎不死鸟
  • 网页图片不清晰怎么办郑州网站优化seo
  • 深圳做网站外包公司有哪些百度seo关键词优化排行
  • 做商城网站要哪些流程图google网址直接打开