gpt4 book ai didi

php - 重设密码电邮

转载 作者:可可西里 更新时间:2023-10-31 23:27:54 26 4
gpt4 key购买 nike

我是 laravel 开发的新手,目前正在做一个小项目。我想为重置密码自定义电子邮件模板,甚至将其链接到完全不同的模板。对于身份验证脚手架,我使用了 php artisan make:auth 命令。

但是默认的重置密码功能使用默认的 laravel 电子邮件模板。我是否可以创建不同的电子邮件模板并将其链接到重置密码 Controller ?另外我想传入额外的用户信息。

我使用的是 laravel 5.4 版本。

最佳答案

您可以生成一个 Notification 类:

php artisan make:notification ResetPassword

您可以在那里覆盖 toMail() 方法来自定义主题和行。

   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));
}

并自定义整个电子邮件模板。这是 View :resources/views/notification/email.blade.php;

config/app.php 中,你可以更改应用程序名称,默认是 laravel。

关于php - 重设密码电邮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43217818/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com