当前位置:网站首页>Laravel calls a third party to send mail (PHP)
Laravel calls a third party to send mail (PHP)
2022-07-25 09:32:00 【yu-yuan】
composer An integrated Tencent cloud 、 SMS treasure is a tool for sending SMS :
composer require mrwanghongda/sms-sdkThe controller class file introduces this class file :
use Mrwanghongda\SmsSdk\Sms\SmsFactory;Controller class file constants :
/**
* SMS treasure
*/
const SMS_BAO = 'bao';
/**
* Tencent cloud
*/
const SMS_TENCENT = 'tencent'; Controller class file method :
/**
* Send verification code
* @param Request $request
* @return \think\response\Json
*/
function send2(Request $request){
$code=rand(0000,9999);
$tel=$request->post('tel');
// Factory mode
$smsObj = (new SmsFactory(SmsFactory::SMS_BAO))->getSmsService();
$config = [
/* Fill in the... Corresponding to the platform CAM The key secretId, SMS Bao fills in the platform account */
'secretId' => '',
/* Fill in the... Corresponding to the platform CAM The key secretKey, SMS Bao fills in the platform password */
'secretKey' => '',
/* SMS app ID: SMS SdkAppId stay [ SMS console ] Add the actual generated after the application SdkAppId, For example 1400006666 , SMS treasure is empty by default */
'smsSdkAppId' => '',
/* Verification Code , For example 5039 */
'code' => $code,
/* Fill in Tencent 、 Signature content corresponding to Alibaba platform , SMS treasure is empty by default */
'signName' => '',
/* Mobile number sent , For example 17899873465 */
'tel' => $tel,
/* Templates ID: The approved template must be filled in ID. Templates ID You can log in [ SMS console ] see */
'templateId' => "",
/* The SMS content sent by the template , SMS treasure needs to fill in Such as :"【 SMS treasure 】 Your verification code is "5390",3 Minutes are valid .", tencent 、 Ali defaults to null */
'content' => '【 SMS treasure 】 Your verification code is '.$code.',3 Minutes are valid .',//
];
$result = $smsObj->send($config);
return json([
'code'=>200,
'msg'=>' success ',
'data'=>$config['content']
]);
}边栏推荐
- Jspdf generates PDF files. There is a problem of incomplete files. Files are downloaded in the background, but not in the foreground
- Click to hide the column in wechat applet, and then click to show it
- < T> Generic method demonstration
- Swagger2 shows that there is a problem with the get interface, which can be solved with annotations
- Go基础4
- Redis安装(Ubuntu)
- 学习 Redis linux 安装Redis
- [HCTF 2018]admin
- 那天帮妹纸装了个数据库。。。就又帮她整理了篇快捷键
- C language and SQL Server database technology
猜你喜欢

Idea practical tips --- now change pom.xml (red) to pom.xml (blue)

在Ubuntu中安装MySQL并创建新用户

How can technologists start their personal brand? Exclusive teaching of top five KOLs

【代码源】每日一题 算的我头都大啦

@3-1 CCF 2020-09-1 称检测点查询

作业7.21 约瑟夫环问题与进制转换

最短路问题 Bellman-Ford(单源最短路径)(图解)

Week小结

变量名可以用中文?直接把人干蒙了

Stm32+hc05 serial port Bluetooth design simple Bluetooth speaker
随机推荐
Interviewer: tell me the difference between redis and mongodb? [easy to understand]
sqli-labs安装 环境:ubuntu18 php7
@1-1 CCF 2021-04-1 灰度直方图
C language and SQL Server database technology
单例模式(Singleton)
main函数的一些操作
~4.1 剑指 Offer 05. 替换空格
【cf】Round 128 C. Binary String
【代码源】每日一题 分数拆分
Click to hide the column in wechat applet, and then click to show it
多态和接口
梦想启航(第一篇博客)
Stm32+hc05 serial port Bluetooth design simple Bluetooth speaker
~4.2 ccf 2021-12-1 序列查询
idea 热部署
Go基础4
Go foundation 2
MySQL appends a string to the string of a field in the table [easy to understand]
正奇边形可划分成多少区域
¥1-3 SWUST oj 942: 逆置顺序表