easySms + Thinkphp5+
# easySms
$ composer require "overtrue/easy-sms"
<?php declare (strict_types = 1); namespace app\index\controller; use Overtrue\EasySms\EasySms; class Index extends \app\BaseController { /** * 首页 */ public function index() { $code = rand_string(4,1); $mobile = '13221733886'; $smsTpl = 'SMS_227470037'; $smsConfig = config('sms_config'); $easySms = new EasySms($smsConfig); $easySms->send($mobile, [ 'template' => $smsTpl, 'data' => [ 'code' => $code ], ]); return $this->fetch(); } }