|
@@ -34,6 +34,10 @@ class MailCaptcha extends BaseService
|
|
|
|
|
|
// 发送限制间隔时间,默认24小时
|
|
|
protected int $safeTime = 86400;
|
|
|
+ //验证码过期时间
|
|
|
+ protected int $expireTime = 300;
|
|
|
+ //可重复使用次数
|
|
|
+ protected int $checkTimes = 5;
|
|
|
|
|
|
/**
|
|
|
* 发送邮件验证码
|
|
@@ -64,7 +68,9 @@ class MailCaptcha extends BaseService
|
|
|
return false;
|
|
|
}
|
|
|
// 生成验证码
|
|
|
- $smsCaptcha = CaptchaApi::createSMS($email);
|
|
|
+ //$smsCaptcha = CaptchaApi::createSMS($email);
|
|
|
+ $smsCaptcha = (string)mt_rand(100000, 999999);
|
|
|
+ Cache::set("captchaSMS.{$email}", ['code' => $smsCaptcha, 'times' => $this->checkTimes], $this->expireTime);
|
|
|
|
|
|
$mail = new PHPMailer(true);
|
|
|
//dd(config('smtp'));
|
|
@@ -101,7 +107,7 @@ class MailCaptcha extends BaseService
|
|
|
//Content
|
|
|
//$mail->isHTML(true); //Set email format to HTML
|
|
|
$mail->Subject = 'Password';
|
|
|
- $mail->Body = 'Your captcha is ' . $smsCaptcha['code'] . '.Please use it in 15 minutes';
|
|
|
+ $mail->Body = 'Your captcha is ' . $smsCaptcha . '.Please use it in 15 minutes';
|
|
|
$mail->AltBody = 'This is the Your captcha for Free Shipping Vapes';
|
|
|
|
|
|
$mail->send();
|
|
@@ -180,7 +186,7 @@ class MailCaptcha extends BaseService
|
|
|
}
|
|
|
// 判断发送次数是否合法
|
|
|
if ($record['times'] <= 0) {
|
|
|
- $this->error = '很抱歉,已超出今日最大发送次数限制';
|
|
|
+ $this->error = 'Sorry,up to the limit today.';
|
|
|
return false;
|
|
|
}
|
|
|
// 发送次数递减
|
|
@@ -208,12 +214,13 @@ class MailCaptcha extends BaseService
|
|
|
|
|
|
public function checkCaptcha($captchaCode = '', $email = '')
|
|
|
{
|
|
|
- if ($captchaCode == '888888') {
|
|
|
- return true;
|
|
|
- }
|
|
|
+// if ($captchaCode == '888888') {
|
|
|
+// return true;
|
|
|
+// }
|
|
|
$localCode = Cache::get('captchaSMS.' . $email);
|
|
|
if (empty($localCode) || empty($localCode['code']) || $localCode['code'] != $captchaCode) {
|
|
|
throwError('Sorry,your captcha is invalid');
|
|
|
}
|
|
|
+ return true;
|
|
|
}
|
|
|
}
|