register($email); case "forgetPassword": return $this->forgetPassword($email); default: throw new ClientException("source未匹配"); } } private function register($email): bool { $captcha = Cache::remember("email:registerCaptcha" . $email, 10, function () { return rand(100000, 999999); }); try { Mail::to($email)->send(new RegisterEmail($captcha)); } catch (\Exception $e) { logger()->error("邮件发送失败 " . $e->getMessage()); throw new ClientException("邮件发送失败,请稍后再试"); } return true; } private function forgetPassword($email): bool { $captcha = Cache::remember("email:forgetPasswordCaptcha" . $email, 10, function () { return rand(100000, 999999); }); try { Mail::to($email)->send(new ForgetPasswordEmail($captcha)); } catch (\Exception $e) { logger()->error("邮件发送失败 " . $e->getMessage()); throw new ClientException("邮件发送失败,请稍后再试"); } return true; } }