public function sendmailtest() { SendCloud::sendTemplate('test_template_active', ['%url%' => ['www.baidu.com']], function (SendCloudMessage $message) { $message->to(['*****@*****.**'])->subject('你好'); })->success(function ($response) { dd($response); })->failure(function ($response, $error) { dd($response); }); return view('sites.about'); }
private function pushTestMail() { $testMail = '*****@*****.**'; $this->info('Push test mail to: ' . $testMail); SendCloud::sendTemplate('ruogu_invite_to_register', [], function (SendCloudMessage $message) use($testMail) { $message->to([$testMail])->subject('若古社区诚邀您入驻'); })->success(function ($response) { })->failure(function ($response, $error) { $this->error($error->message); }); }
/** * 注册 */ public function do_register(UserRegisterRequest $request) { $code_result = RegisterCode::where('register_code', $request->get('register_code'))->where('status', '0')->first(); if (count($code_result) == 0) { return redirect('/register'); } $register_data = ['name' => $request->get('name'), 'email' => $request->get('email'), 'password' => Hash::make($request->get('password')), 'avatar' => '/images/default-avatar.png', 'confirm_code' => str_random(48)]; //写入用户 $save_user_result = User::create($register_data); //更新注册码的状态 $code_result->status = 1; $code_result->use_user_id = $save_user_result->getAttribute('id'); $code_result->save(); //给用户发送邮件 $email = $save_user_result->getAttribute('email'); $confirm_code = $save_user_result->getAttribute('confirm_code'); SendCloud::sendTemplate('test_template_active', ['%url%' => ['http://localhost:8000/confirm_register?confirm_code=' . $confirm_code . '&email=' . $email]], function (SendCloudMessage $message) use($email) { $message->to([$email])->subject('7csa激活注册信息'); })->success(function ($response) use($email) { })->failure(function ($response, $error) { Log::info('注册发送邮件失败:' . $response); }); return redirect('/send_confirm_mail'); }