//安装
composer require "overtrue/easy-sms"
//使用
use Overtrue\EasySms\EasySms;
$config = [
// HTTP 请求的超时时间(秒)
'timeout' => 5.0,
// 默认发送配置
'default' => [
// 网关调用策略,默认:顺序调用
'strategy' => \Overtrue\EasySms\Strategies\OrderStrategy::class,
// 默认可用的发送网关
'gateways' => [
'yunpian', 'aliyun',
],
],
// 可用的网关配置
'gateways' => [
'errorlog' => [
'file' => '/tmp/easy-sms.log',
],
'yunpian' => [
'api_key' => '824f0ff2f71cab52936axxxxxxxxxx',
],
'aliyun' => [
'access_key_id' => '',
'access_key_secret' => '',
'sign_name' => '',
],
//...
],
];
$easySms = new EasySms($config);
$easySms->send(13188888888, [
'content' => '您的验证码为: 6379',
'template' => 'SMS_001',
'data' => [
'code' => 6379
],
]);
//发送模板消息
//$text = $enrolling['student']['name'] . "同学,明日课程:" . $enrolling['kecheng']['name'] . ",时间:" . $class['attend_class_time'] . ",请按时上课,谢谢!";
$easySms = new EasySms($config);
$easySms->send($data['mobile'], [
'content' => '',//$text
'template' => 'SMS_470150011',
'data' => [
'username' => $username,
'course' => $course,
'time' => $time,
],
]);
Easy SMS 发送短信
最新推荐文章于 2025-03-25 17:20:37 发布