当前位置:网站首页>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']
]);
}边栏推荐
猜你喜欢
随机推荐
Analysis of concat and group in MySQL_ Use of concat
[GKCTF 2021]easynode
动态添加多tab,并初始化每个tab页面
~3 ccf 2022-03-2 出行计划
~1 ccf 2022-06-2 寻宝!大冒险!
Read and write mongodb database files
【代码源】每日一题 分数拆分
最短路问题 Bellman-Ford(单源最短路径)(图解)
【代码源】每日一题 算的我头都大啦
¥1-1 SWUST oj 941: 有序顺序表的合并操作的实现
为什么要使用JSON.stringify()和JSON.parse()
一文搞懂try、catch、finally(包含return)执行流程(全网最详细解析)
Deep understanding of static keyword
[selected] from simple to deep, you will understand MQ principles and application scenarios
无法再web服务器上启动调试,web服务器未能找到请求资源
~4.1 剑指 Offer 05. 替换空格
浏览器访问swagger失败,显示错误ERR_UNSAFE_PORT
Install MySQL in Ubuntu and create new users
Thick willow dustpan, thin willow bucket, who hates reptile man? Asynchronous synergism, half a second to strip away a novel
UI——无限轮播图和分栏控制器
![[GYCTF2020]Node Game](/img/8d/7e6c2fb2a0359298fbcc1cd8544710.png)

![[GYCTF2020]Ez_Express](/img/ce/02b90708f215715bb53cacfd4c21f0.png)





