重设密码电邮 [英] Reset Password Email
问题描述
我是laravel开发的新手,目前正在从事小型项目.我想为重置密码自定义电子邮件模板,甚至将其链接到完全不同的模板.对于身份验证支架,我使用了 php artisan make:auth 命令.
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.
但是,默认的重置密码功能使用默认的laravel电子邮件模板.是否可以创建其他电子邮件模板并将其链接到重置密码控制器?另外,我想传入其他用户信息.
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.
我正在使用laravel 5.4版本.
I am using laravel 5.4 version.
推荐答案
您可以使用以下方法生成Notification类:
You can generate a Notification class with:
php artisan make:notification ResetPassword
您可以在此处覆盖toMail()
方法以自定义主题和行.
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.');
}
在users
模型中:
use Illuminate\Notifications\Notifiable;
use App\Notifications\ResetPassword as ResetPasswordNotification;
public function sendPasswordResetNotification($token)
{
$this->notify(new ResetPasswordNotification($token));
}
并自定义整个电子邮件模板.这是视图:resources/views/notification/email.blade.php;
And to customize whole email template. here is the view: resources/views/notification/email.blade.php;
在config/app.php
中,您可以更改应用程序名称,默认值为laravel.
And in config/app.php
, You can change the application name, default is laravel.
这篇关于重设密码电邮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!