Reset Password Email

旧巷老猫 提交于 2019-12-23 12:27:32

问题


I am new to laravel development and currently working on small project. I would like to customize the email template for the reset passwords or even link it to completely different template. For the authentication scaffolding I have used the php artisan make:auth command.

However the default reset password functionality uses default laravel email template. Is it possible that I can create different email template and link it to reset password Controller? Also I would like to pass in additional user information in.

I am using laravel 5.4 version.


回答1:


You can generate a Notification class with:

php artisan make:notification ResetPassword

You can override toMail() method there to customize subject and line.

   public function toMail($notifiable)
    {
        return (new MailMessage)
            ->subject('Reset Password Request')
            ->line('You are receiving this email because we received a password reset request for your account.')
            ->action('Reset Password', url('password/reset', $this->token))
            ->line('If you did not request a password reset, no further action is required.');
    }

And in users model:

   use Illuminate\Notifications\Notifiable;
   use App\Notifications\ResetPassword as ResetPasswordNotification;

    public function sendPasswordResetNotification($token)
        {
            $this->notify(new ResetPasswordNotification($token));
        }

And to customize whole email template. here is the view: resources/views/notification/email.blade.php;

And in config/app.php, You can change the application name, default is laravel.



来源:https://stackoverflow.com/questions/43217818/reset-password-email

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!