easySms = new EasySms(config('sms')); } /** * 发送验证码短信 * * @param string $mobile 手机号 * @param string $code 验证码 * @return bool */ public function sendVerifyCode(string $mobile, string $code): bool { try { $templateId = env('TENCENT_SMS_TEMPLATE_ID'); // TODO: 发送短信方法,记得打开 // $result = $this->easySms->send($mobile, [ // 'template' => $templateId, // 'data' => [ // $code, // 5 // 验证码有效期(分钟) // ], // ]); $result = true; Log::info('SMS sent', [ 'mobile' => $mobile, 'code' => $code, 'result' => $result ]); return true; } catch (\Exception $e) { Log::error('SMS sending failed', [ 'mobile' => $mobile, 'error' => $e->getMessage() ]); throw $e; } } }