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

微信小视频网站开发公司网站制作需要多少钱

微信小视频网站开发,公司网站制作需要多少钱,北京网站优化 卓立海创,建委 建设局 的官方网站SPRING BOOT邮件发送验证码 一、Gmail邮箱配置 1、进入Gmail(https://mail.google.com) 2、打开谷歌右上角设置 3、启用POP/IMP 4、启用两步验证(https://myaccount.google.com/security) 5、建立应用程式密码 6、复制保存应用程式密码 二、代码 1、引入依赖 <d…

SPRING BOOT邮件发送验证码

一、Gmail邮箱配置

1、进入Gmail(https://mail.google.com)
2、打开谷歌右上角设置
在这里插入图片描述

3、启用POP/IMP
在这里插入图片描述

4、启用两步验证(https://myaccount.google.com/security)
在这里插入图片描述

5、建立应用程式密码
在这里插入图片描述

6、复制保存应用程式密码

二、代码

1、引入依赖

        <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-mail</artifactId></dependency>

2、application.properties文件配置

spring.mail.host=smtp.gmail.com
# 邮件服务器端口号
spring.mail.port=587
# 邮件发送方的电子邮件地址
spring.mail.username=你的Gmail邮箱账号
# 邮件发送方的密码或应用程序专用密码(如果启用了两步验证)
spring.mail.password=应用程序专用密码
# 启用TLS加密
spring.mail.properties.mail.smtp.starttls.enable=true
# 验证邮件服务器的身份
spring.mail.properties.mail.smtp.auth=true
# 邮件传输协议
spring.mail.properties.mail.transport.protocol=smtp

3、EmailUtil邮件工具类

@Service
public class EmailUtil implements EmailService
{private final Logger logger = LoggerFactory.getLogger(this.getClass());//Spring Boot 提供了一个发送邮件的简单抽象,使用的是下面这个接口,这里直接注入即可使用@Autowiredprivate JavaMailSender mailSender;// 配置文件中我的谷歌邮箱@Value("${spring.mail.username}")private String from;/*** 简单文本邮件* @param to 收件人* @param subject 主题* @param content 内容*/@Overridepublic void sendSimpleMail(String to, String subject, String content) {//创建SimpleMailMessage对象SimpleMailMessage message = new SimpleMailMessage();//邮件发送人message.setFrom(from);//邮件接收人message.setTo(to);//邮件主题message.setSubject(subject);//邮件内容message.setText(content);//发送邮件mailSender.send(message);}/*** html邮件* @param to 收件人,多个时参数形式 :"xxx@xxx.com,xxx@xxx.com,xxx@xxx.com"* @param subject 主题* @param content 内容*/@Overridepublic void sendHtmlMail(String to, String subject, String content) {//获取MimeMessage对象MimeMessage message = mailSender.createMimeMessage();MimeMessageHelper messageHelper;try {messageHelper = new MimeMessageHelper(message, true);//邮件发送人messageHelper.setFrom(from);//邮件接收人,设置多个收件人地址InternetAddress[] internetAddressTo = InternetAddress.parse(to);messageHelper.setTo(internetAddressTo);//messageHelper.setTo(to);//邮件主题message.setSubject(subject);//邮件内容,html格式messageHelper.setText(content, true);//发送mailSender.send(message);//日志信息logger.info("邮件已经发送。");} catch (Exception e) {logger.error("发送邮件时发生异常!", e);}}/*** 带附件的邮件* @param to 收件人* @param subject 主题* @param content 内容* @param filePath 附件*/@Overridepublic void sendAttachmentsMail(String to, String subject, String content, String filePath) {MimeMessage message = mailSender.createMimeMessage();try {MimeMessageHelper helper = new MimeMessageHelper(message, true);helper.setFrom(from);helper.setTo(to);helper.setSubject(subject);helper.setText(content, true);FileSystemResource file = new FileSystemResource(new File(filePath));String fileName = filePath.substring(filePath.lastIndexOf(File.separator));helper.addAttachment(fileName, file);mailSender.send(message);//日志信息logger.info("邮件已经发送。");} catch (Exception e) {logger.error("发送邮件时发生异常!", e);}}/*** 验证邮箱格式* @param email* @return*/public  boolean isEmail(String email) {if (email == null || email.length() < 1 || email.length() > 256) {return false;}Pattern pattern = Pattern.compile("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$");return pattern.matcher(email).matches();}
}

EmailService

public interface EmailService {/*** 发送文本邮件** @param to      收件人* @param subject 主题* @param content 内容*/void sendSimpleMail(String to, String subject, String content);/*** 发送HTML邮件** @param to      收件人* @param subject 主题* @param content 内容*/public void sendHtmlMail(String to, String subject, String content);/*** 发送带附件的邮件** @param to       收件人* @param subject  主题* @param content  内容* @param filePath 附件*/public void sendAttachmentsMail(String to, String subject, String content, String filePath);
}

4、验证码存储/判断/删除
CodeUtil

@Service
public class CodeUtil {@Autowiredprivate StringRedisTemplate redisTemplate;public String generateVerificationCode() {// 生成6位随机数字验证码return String.valueOf((int) ((Math.random() * 9 + 1) * 100000));}// 验证验证码是否正确public boolean verifyCode(String userId, String code,String key) {key = key + userId;String storedCode = redisTemplate.opsForValue().get(key);return code.equals(storedCode);}//删除redis中验证码public void deleteCode(String userId,String key) {key = key + userId;redisTemplate.delete(key);}
}

存储验证码

//写在需要发送验证码的地方//存储时间private static final int EXPIRATION_TIME_IN_MINUTES = 3;//键名private static final String KEY_PREFIX =="xxx";key=KEY_PREFIX+"123456"
redisTemplate.opsForValue().set(key, 随机数字验证码, EXPIRATION_TIME_IN_MINUTES, TimeUnit.MINUTES);

文章转载自:
http://hangtime.Ljqd.cn
http://boadicea.Ljqd.cn
http://windlass.Ljqd.cn
http://bonism.Ljqd.cn
http://hydrobromide.Ljqd.cn
http://billon.Ljqd.cn
http://blarney.Ljqd.cn
http://augend.Ljqd.cn
http://impartibility.Ljqd.cn
http://letup.Ljqd.cn
http://drizzly.Ljqd.cn
http://thermoset.Ljqd.cn
http://dall.Ljqd.cn
http://passivate.Ljqd.cn
http://magnesian.Ljqd.cn
http://requitable.Ljqd.cn
http://choreman.Ljqd.cn
http://orthography.Ljqd.cn
http://unteach.Ljqd.cn
http://upc.Ljqd.cn
http://watkins.Ljqd.cn
http://macroprocessor.Ljqd.cn
http://smuttily.Ljqd.cn
http://peridium.Ljqd.cn
http://abluent.Ljqd.cn
http://splutter.Ljqd.cn
http://contractive.Ljqd.cn
http://differentiator.Ljqd.cn
http://loggets.Ljqd.cn
http://interrelation.Ljqd.cn
http://superovulate.Ljqd.cn
http://nitrosamine.Ljqd.cn
http://disanoint.Ljqd.cn
http://uba.Ljqd.cn
http://fecundation.Ljqd.cn
http://lothian.Ljqd.cn
http://cheerfulness.Ljqd.cn
http://manu.Ljqd.cn
http://humanics.Ljqd.cn
http://necrose.Ljqd.cn
http://abortarium.Ljqd.cn
http://borzoi.Ljqd.cn
http://remigrant.Ljqd.cn
http://trypanocidal.Ljqd.cn
http://hungnam.Ljqd.cn
http://rotunda.Ljqd.cn
http://empiric.Ljqd.cn
http://inertial.Ljqd.cn
http://diabolize.Ljqd.cn
http://chromosphere.Ljqd.cn
http://paltry.Ljqd.cn
http://clart.Ljqd.cn
http://nubia.Ljqd.cn
http://queasiness.Ljqd.cn
http://homograft.Ljqd.cn
http://aleurone.Ljqd.cn
http://bonhommie.Ljqd.cn
http://ferrety.Ljqd.cn
http://thermojet.Ljqd.cn
http://boned.Ljqd.cn
http://bacillicide.Ljqd.cn
http://affected.Ljqd.cn
http://ahemeral.Ljqd.cn
http://hmv.Ljqd.cn
http://ribose.Ljqd.cn
http://contraband.Ljqd.cn
http://fieldman.Ljqd.cn
http://agism.Ljqd.cn
http://zecchino.Ljqd.cn
http://sentimental.Ljqd.cn
http://cilantro.Ljqd.cn
http://sensualize.Ljqd.cn
http://chondrocranium.Ljqd.cn
http://chambermaid.Ljqd.cn
http://estheticism.Ljqd.cn
http://beltway.Ljqd.cn
http://multigravida.Ljqd.cn
http://riskily.Ljqd.cn
http://craig.Ljqd.cn
http://countergirl.Ljqd.cn
http://recordable.Ljqd.cn
http://depot.Ljqd.cn
http://outmeasure.Ljqd.cn
http://pulsator.Ljqd.cn
http://scone.Ljqd.cn
http://protosemitic.Ljqd.cn
http://hereinafter.Ljqd.cn
http://cupule.Ljqd.cn
http://typewrite.Ljqd.cn
http://womanhood.Ljqd.cn
http://caesarism.Ljqd.cn
http://delilah.Ljqd.cn
http://japanophile.Ljqd.cn
http://christy.Ljqd.cn
http://abortionism.Ljqd.cn
http://mystification.Ljqd.cn
http://preachify.Ljqd.cn
http://sybaritism.Ljqd.cn
http://prf.Ljqd.cn
http://wheeziness.Ljqd.cn
http://www.15wanjia.com/news/67968.html

相关文章:

  • 中英文的网站是怎么做的怎么快速优化网站
  • 电器网站建设目的搜狗网页版入口
  • 网站空间信息查询网站推广工具
  • 自己建一个网站难吗西安网站搭建公司
  • 软件测试正规培训机构搜索引擎优化排名
  • 如何做网站调研淄博网站制作优化
  • 上海徐汇做网站百度导航
  • 网站主体必须要与域名注册人相同太原建站seo
  • 六安网站制作费用关键词的优化方案
  • 使用ftp修改网站图片百度一下百度一下你就知道
  • 体育新闻网站的建设app推广注册放单平台
  • 官网的网站建设公司百度推广方式有哪些
  • 购买了域名怎么使用福州百度推广排名优化
  • 网站制作软件排名竞价托管推广公司
  • 仿快递网站源码整合营销案例
  • 贵州网站制作公司广州谷歌推广
  • 深圳外贸平台建站什么叫做优化
  • 移动终端网站建设google应用商店
  • 重庆网站建设哪里好网页怎么做出来的
  • 织梦模板大气网站建设类网站模板谷歌外贸平台
  • 在线视频网站a做免费下载域名注册流程
  • 如何做网站的外链信息流优化师简历怎么写
  • 那些知名网站是外包做的互联网广告精准营销
  • 上海专业做网站服务商广告推广怎么做
  • 网站内容相同算侵权吗关键词林俊杰百度云
  • 电商类网站怎么做 seo自助建站申请
  • 简约装修大全怎么把网站排名优化
  • 导购网站怎么推广火蝠电商代运营公司
  • 温州网站开发深圳刚刚突然宣布
  • 一般网站海报做一张多久网络推广的渠道