亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Laravel 將激活鏈接發送到特定電子郵件

Laravel 將激活鏈接發送到特定電子郵件

PHP
胡說叔叔 2022-07-09 17:00:23
我希望注冊后的激活鏈接發送到一個電子郵件,這是因為我不希望每個人都創建一個管理員帳戶,所以任何人創建一個管理員帳戶應用程序的所有者將通過點擊他的激活鏈接來激活他的帳戶電子郵件(所有者電子郵件)。protected function postAdminRegistration(Request $request){    $validatedData = $request->validate([        'name' => 'required|string|max:255',        'email' => 'required|string|email|max:255|unique:users',        'password' => 'required|string|min:6|confirmed',    ]);    try {        $validatedData['password'] = bcrypt(array_get($validatedData, 'password'));        $validatedData['activation_code'] = str_random(30).time();        $user = app(User::class)->create($validatedData);    } catch (\Exception $exception) {        logger()->error($exception);        return redirect()->back()->with('message', 'Unable to create new user.');    }    $user->notify(new UserRegisteredSuccessfully($user));    return redirect()->route("user.loginform")->withSuccess('Successfully created a new account.        Please check your email and activate your account.');}用戶注冊成功public function toMail($notifiable){    $user = $this->user;    return (new MailMessage)        ->from('****@gmail.com')        ->subject('Successfully created new account')        ->greeting(sprintf('Hello %s', $user->fname))        ->line('You have successfully registered to our system. Please activate your account.')        ->action('Click Here',            route('user.activate', $user->activation_code))->line('Thank you for using our application!');}模型class User extends Authenticatable{use Notifiable;protected $fillable = ['name','email','password'];protected static $logFillable = true;protected $hidden = [    'password', 'remember_token',];public function sendPasswordResetNotification($token){$this->notify(new ResetPassword($token.'/'.$this->email));}}
查看完整描述

2 回答

?
慕婉清6462132

TA貢獻1804條經驗 獲得超2個贊

添加到代碼中的方法


return (new MailMessage)

    ->from('****@gmail.com')

    ->to("[email protected]")


     ...

更多詳情https://laravel.com/docs/6.x/notifications


查看完整回答
反對 回復 2022-07-09
?
紫衣仙女

TA貢獻1839條經驗 獲得超15個贊

無法添加評論,所以我以這種方式發布可能的答案;我假設您可以通過以下方式添加收件人 ->to('[email protected]')



查看完整回答
反對 回復 2022-07-09
  • 2 回答
  • 0 關注
  • 123 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號