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

公司网站开发说明介绍公司网站

公司网站开发说明介绍,公司网站,网站策划书ppt,有没有专门做外贸的网站目录 引出springboot整合email配置邮箱导入依赖application.yml配置email业务类测试类 springboot整合阿里云短信服务申请阿里云短信服务测试短信服务获取阿里云的accessKeyspringboot整合阿里云短信导包工具类 总结 引出 1.springboot整合email,qq邮箱,…

目录

  • 引出
  • springboot整合email
    • 配置邮箱
    • 导入依赖
    • application.yml配置
    • email业务类
    • 测试类
  • springboot整合阿里云短信服务
    • 申请阿里云短信服务
    • 测试短信服务
    • 获取阿里云的accessKey
    • springboot整合阿里云短信
      • 导包
      • 工具类
  • 总结

引出


1.springboot整合email,qq邮箱,特点免费;
2.springboot整合阿里短信服务,100条免费;
3.后续应用,可以用在登陆业务上,比如邮箱登陆,短信登陆;

springboot整合email

配置邮箱

登录邮箱服务器: 登录QQ邮箱

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

后面要用到这个授权码key

在这里插入图片描述

导入依赖

<!--        qq邮箱--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-mail</artifactId></dependency>

application.yml配置

在这里插入图片描述

在这里插入图片描述

email业务类

接口

package com.tianju.auth.service;public interface IEmailService {/*** 发送右键* @param to 邮件接收方* @param subject 邮件主题* @param content 邮件内容*/void sendEmail(String to,String subject,String content);
}

实现

package com.tianju.auth.service.impl;import com.tianju.auth.service.IEmailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;import javax.annotation.Resource;
import java.util.Date;@Service
@Slf4j
public class EmailServiceImpl implements IEmailService {@Value("${spring.mail.username}")private String from;@Resourceprivate JavaMailSender javaMailSender;@Overridepublic void sendEmail(String to, String subject, String content) {SimpleMailMessage mailMessage = new SimpleMailMessage();mailMessage.setSubject(subject);mailMessage.setTo(to);mailMessage.setText(content);mailMessage.setSentDate(new Date());mailMessage.setFrom(from);javaMailSender.send(mailMessage);log.debug("在{}发送一条邮件{}给{}",mailMessage.getSentDate(),mailMessage.getText(),mailMessage.getTo());}
}

测试类

package com.tianju.auth.service.impl;import com.tianju.auth.service.IEmailService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;import javax.xml.ws.soap.Addressing;import java.util.UUID;import static org.junit.Assert.*;@SpringBootTest
@RunWith(SpringJUnit4ClassRunner.class)
public class EmailServiceImplTest {@Autowiredprivate IEmailService emailService;@Testpublic void sendEmail() {emailService.sendEmail("xxxx@qq.com", "我是老王,我在测试代码", UUID.randomUUID().toString());}
}

springboot整合阿里云短信服务

申请阿里云短信服务

短信服务 (aliyun.com)

在这里插入图片描述

测试短信服务

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

进行测试

在这里插入图片描述

在这里插入图片描述

调用结果

在这里插入图片描述

成功接收短信

在这里插入图片描述

获取阿里云的accessKey

在这里插入图片描述

在这里插入图片描述

springboot整合阿里云短信

导包

        <!--        阿里云短信验证码相关包--><dependency><groupId>com.aliyun</groupId><artifactId>aliyun-java-sdk-core</artifactId><version>4.5.3</version></dependency>

工具类

package com.tianju.auth.util;import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;
import net.minidev.json.JSONObject;import java.util.HashMap;
import java.util.Map;
import java.util.Random;public class SMSUtil {private static String AccessIdKey = "获取的keyID";private static String AccessKeySecret = "获取的KeySecret";public static void send(String tel,String code) {DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou",AccessIdKey, //AccessIdKeyAccessKeySecret); //AccessKey SecretIAcsClient client = new DefaultAcsClient(profile);CommonRequest request = new CommonRequest();request.setSysMethod(MethodType.POST);//下面这3个不要改动request.setSysDomain("dysmsapi.aliyuncs.com");request.setSysVersion("2017-05-25");request.setSysAction("SendSms");//接收短信的手机号码request.putQueryParameter("PhoneNumbers",tel);//此处写电话号码//短信签名名称request.putQueryParameter("SignName","阿里云短信测试");//短信模板IDrequest.putQueryParameter("TemplateCode","SMS_154950909");//短信模板变量对应的实际值 ${code} 中的值Map<String,String> param = new HashMap<>(2);param.put("code", String.valueOf(code)); //写入的短信内容,验证码request.putQueryParameter("TemplateParam", JSONObject.toJSONString(param));try {CommonResponse response = client.getCommonResponse(request);System.out.println(response.getData());} catch (ServerException e) {e.printStackTrace();} catch (ClientException e) {e.printStackTrace();}}public static void main(String[] args) {int i = new Random().nextInt(80000) + 10000;System.out.println(i); // 35054SMSUtil.send("xxxx", "392712");}}

在这里插入图片描述


总结

1.springboot整合email,qq邮箱,特点免费;
2.springboot整合阿里短信服务,100条免费;
3.后续应用,可以用在登陆业务上,比如邮箱登陆,短信登陆;

http://www.tj-hxxt.cn/news/5754.html

相关文章:

  • 国外活动策划网站企业网站设计优化公司
  • 论述营销型网站的评价标准买卖网交易平台
  • 上海建科建设监理网站网站开发平台有哪些
  • 可以做蛋白三位结构图的网站域名网站
  • 网站要什么备案关键词排名点击软件怎样
  • 怎么做自己下单的网站淘宝热搜关键词排行榜
  • 国内最大c2c网站个人如何在百度做广告
  • 建设一个网站需要哪些费用吗网络营销师报名入口
  • 外贸网站制作公司智慧软文发稿平台
  • php做简单网站教程视频教程线下推广有哪些渠道
  • 长春火车站到机场怎么走微信腾讯会议
  • wordpress商品多选怎么快速优化网站
  • 做家庭影院的有哪些网站市场调研的方法有哪些
  • 微网站需要什么技术seo优化网
  • 做网站的工作轻松吗怎样建网站赚钱
  • 网站建设 收费标准郑州seo优化外包
  • 成都seo网站开发seo网站推广软件
  • 天河网站建设公司广点通广告投放平台
  • 聊城企业做网站推广搜索引擎查关键词排名的软件
  • 宁波网站建设报价多少小程序拉新推广平台
  • 网站建设推广重要性企业品牌推广营销方案
  • 源代码做网站seo的优化技巧和方法
  • 网站建设 外包是什么意思福州seo外包公司
  • 盘锦网站建设郑州网络营销
  • 版式设计1000例seo搜索优化工具
  • 布吉做棋牌网站建设找哪家效益快想要网站导航推广页
  • 网站流百度网站怎么申请注册
  • 网站做要钱北京疫情又严重了
  • 网站百度地图标记代码国外搜索引擎排行榜
  • git做网站根目录最全磁力搜索引擎