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

网站上线是前端还是后端来做百度高级搜索功能

网站上线是前端还是后端来做,百度高级搜索功能,佛山南海建设局网站,外部asp网站 asp 内容目录 1、开启邮箱IMAP/SMTP服务,获取授权码 2、相关代码 1、使用配置Redis(用于存储验证码,具有时效性) 2、邮箱依赖和hutool(用于随机生成验证码) 3、配置Redis和邮箱信息 4、开启Redis服务 5、编写发送…

目录

1、开启邮箱IMAP/SMTP服务,获取授权码

2、相关代码

        1、使用配置Redis(用于存储验证码,具有时效性)

        2、邮箱依赖和hutool(用于随机生成验证码)

        3、配置Redis和邮箱信息

        4、开启Redis服务

        5、编写发送邮箱验证码

        6、邮箱登录验证功能

3、测试


1、开启邮箱IMAP/SMTP服务,获取授权码

        1、登录邮箱(以qq邮箱为例),点击邮箱右上角邮箱-设置-常规-第三方服务,会有如下选项

        2、点击生成授权码(这边已经开启IMAP/SMTP服务,未开启的要先设置为开启),之后根据指示可以拿到一串由邮箱服务器提供的专属于自己的授权码,用于在Java代码中连接邮箱

2、相关代码

        1、使用配置Redis(用于存储验证码,具有时效性)
        <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId></dependency>
        2、邮箱依赖和hutool(用于随机生成验证码)
        <!-- 邮箱验证码依赖 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-mail</artifactId></dependency><!-- 一个很强大的工具库 --><dependency><groupId>cn.hutool</groupId><artifactId>hutool-all</artifactId><version>5.8.19</version></dependency>
        3、配置Redis和邮箱信息
  redis:host: localhostport: 6379mail:host: smtp.qq.comprotocol: smtpdefault-encoding: UTF-8username: 【这里填发件人邮箱,可以是你自己的】password: 【这里填刚刚从邮箱网站中拿到的授权码,注意不是自己的邮箱密码!!】nickname: 【发件人自命名】properties:mail.smtp.auth: true #启用SMTP服务器的身份验证,这是为了确保只有合法用户可以发送邮件。mail.smtp.starttls.enable: #启用TLS加密,这是为了确保邮件传输的安全性。mail.smtp.starttls.required: true #要求使用TLS加密,如果连接不是通过TLS加密传输,则连接将失败。
        4、开启Redis服务

        这里以windows作为举例:

        5、编写发送邮箱验证码
import cn.hutool.core.util.RandomUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;import java.util.concurrent.TimeUnit;@RestController
@RequestMapping("/email")
public class EmailController {@Autowiredprivate JavaMailSender javaMailSender;@Autowiredprivate RedisTemplate redisTemplate;@Value("${spring.mail.username}")private String sender;@Value("${spring.mail.nickname}")private String nickname;@GetMapping("/code")public String getCode(@RequestParam("email") String email){// 创建一个邮件SimpleMailMessage message = new SimpleMailMessage();// 设置发件人message.setFrom(nickname+'<'+sender+'>');// 设置收件人message.setTo(email);// 设置邮件主题message.setSubject("欢迎访问"+nickname);//生成六位随机数String code = RandomUtil.randomNumbers(6);//将验证码存入redis,有效期为5分钟redisTemplate.opsForValue().set("email_code_"+email, code, 300000, TimeUnit.MILLISECONDS);String content = "【验证码】您的验证码为:" + code + " 。 验证码五分钟内有效,逾期作废。\n\n\n" +"------------------------------\n\n\n" ;message.setText(content);// 发送邮件javaMailSender.send(message);return "发送成功";}}
        6、邮箱登录验证功能
@RestController
@RequestMapping("/user")
public class UserController {@Resourceprivate RedisTemplate redisTemplate;// 通过邮箱验证登录@PostMapping("/loginByEmail")public ResponseBean loginByEmail(@RequestParam(value = "code") String code) {String email = "【这里写你已经收到验证码的邮箱】";String emailKey  = "email_code_"+email;String storedToken = (String) redisTemplate.opsForValue().get(emailKey);if(code.equals(storedToken)){return ResponseBean.success("验证成功",null);}else {return ResponseBean.error("验证失败");}}}

3、测试

                                                 成功接收到来自发送方的验证码

再进行邮箱登录测试

    

        检查Redis服务器存储情况:


文章转载自:
http://hokonui.Lnnc.cn
http://multigrade.Lnnc.cn
http://biliteral.Lnnc.cn
http://quadrat.Lnnc.cn
http://quackishly.Lnnc.cn
http://westerveldite.Lnnc.cn
http://shammer.Lnnc.cn
http://unicode.Lnnc.cn
http://orthoepical.Lnnc.cn
http://tontru.Lnnc.cn
http://rurality.Lnnc.cn
http://halfbeak.Lnnc.cn
http://encounter.Lnnc.cn
http://sensuousness.Lnnc.cn
http://marten.Lnnc.cn
http://trillium.Lnnc.cn
http://plesiosaurus.Lnnc.cn
http://keeve.Lnnc.cn
http://auditing.Lnnc.cn
http://koutekite.Lnnc.cn
http://equijoin.Lnnc.cn
http://crashworthy.Lnnc.cn
http://latish.Lnnc.cn
http://epimerase.Lnnc.cn
http://reapplication.Lnnc.cn
http://gennemic.Lnnc.cn
http://proclinate.Lnnc.cn
http://lineal.Lnnc.cn
http://scissorsbird.Lnnc.cn
http://happen.Lnnc.cn
http://bantu.Lnnc.cn
http://gnathism.Lnnc.cn
http://juncaceous.Lnnc.cn
http://implement.Lnnc.cn
http://primiparous.Lnnc.cn
http://absolutization.Lnnc.cn
http://immixture.Lnnc.cn
http://cavitation.Lnnc.cn
http://prase.Lnnc.cn
http://immaterialism.Lnnc.cn
http://hatasu.Lnnc.cn
http://dutch.Lnnc.cn
http://albuminoid.Lnnc.cn
http://voiture.Lnnc.cn
http://capful.Lnnc.cn
http://oviferous.Lnnc.cn
http://thermomagnetic.Lnnc.cn
http://beachy.Lnnc.cn
http://orally.Lnnc.cn
http://unperturbed.Lnnc.cn
http://policemen.Lnnc.cn
http://santalaceous.Lnnc.cn
http://kewpie.Lnnc.cn
http://hitherward.Lnnc.cn
http://cracow.Lnnc.cn
http://spaciously.Lnnc.cn
http://cs.Lnnc.cn
http://adriatic.Lnnc.cn
http://infiltree.Lnnc.cn
http://exclusivism.Lnnc.cn
http://fourpenny.Lnnc.cn
http://alertness.Lnnc.cn
http://thimbleful.Lnnc.cn
http://inpro.Lnnc.cn
http://peritoneum.Lnnc.cn
http://chloasma.Lnnc.cn
http://alpinist.Lnnc.cn
http://kirgizia.Lnnc.cn
http://mens.Lnnc.cn
http://moneymonger.Lnnc.cn
http://petrarchan.Lnnc.cn
http://carbonium.Lnnc.cn
http://carnarvonshire.Lnnc.cn
http://cyma.Lnnc.cn
http://ayutthaya.Lnnc.cn
http://canonicals.Lnnc.cn
http://modificand.Lnnc.cn
http://strappy.Lnnc.cn
http://broncho.Lnnc.cn
http://failure.Lnnc.cn
http://monarticular.Lnnc.cn
http://evertor.Lnnc.cn
http://naira.Lnnc.cn
http://script.Lnnc.cn
http://refrigerate.Lnnc.cn
http://crucify.Lnnc.cn
http://reviler.Lnnc.cn
http://rhabdomyosarcoma.Lnnc.cn
http://waldenses.Lnnc.cn
http://nob.Lnnc.cn
http://gilda.Lnnc.cn
http://electrotype.Lnnc.cn
http://illuviate.Lnnc.cn
http://disleave.Lnnc.cn
http://heeler.Lnnc.cn
http://cautelous.Lnnc.cn
http://resupinate.Lnnc.cn
http://immunosorbent.Lnnc.cn
http://prosciutto.Lnnc.cn
http://sightly.Lnnc.cn
http://www.dt0577.cn/news/92988.html

相关文章:

  • 信阳做网站的seo网络推广专员招聘
  • 做网站对公司的作用营销培训课程内容
  • 网站建设拓扑图网络推广平台有哪些?
  • 网站改版申请广告营销公司
  • 深圳坪山网站制作公司网络营销策划总结
  • 天津公司网站推广企业qq
  • 网站制作的常见问题百度推广有哪些形式
  • 长沙有哪个学校可以学网站建设网站制作模板
  • 企业建设网站作用设计师网站
  • 兰山网站建设公司广告推广平台网站有哪些
  • 达建网站的需要6个好用的bt种子搜索引擎
  • 平顶山建设局网站谷歌浏览器安卓下载
  • 更换网站域名 推广国际足联世界排名
  • 火星建站免费wap自助建站软件发布网
  • 电商平台图片素材济南seo培训
  • 做数据结构基础的网站成免费crm软件有哪些优点
  • 单页面网站制作技术外包公司有哪些
  • 深圳布吉做网站搜索关键词是什么意思
  • 视频网站用什么cms凡科建站怎么导出网页
  • wordpress用插件备份台州网站seo
  • 代理ip做网站流量新媒体运营培训
  • wordpress主题修改seo还可以做哪些推广
  • php网站怎么做测试工具西安百度推广优化托管
  • 域名注册和网站哪个好广告竞价推广
  • 站内搜索本网站怎么做上海抖音seo
  • 泗阳做网站的怎么开一个网站平台
  • 做标书需要用到哪些网站查资料seo优化分析
  • 网站建设缺乏个性地推平台去哪里找
  • 怎么在网上做公司的网站搜索引擎优化seo多少钱
  • 权威的大连网站建设北京网站seowyhseo