在Laravel 5.2上,我可以通过将以下代码放在config / auth.php文件中来配置邮件模板。
'passwords' => [
'users' => [
'provider' => 'users',
'email' => 'auth.emails.password',
'table' => 'password_resets',
'expire' => 1440,
],
],
这将使用我的resources / views / auth / emails / password.blade.php文件,我可以在其中自定义电子邮件的外观。但它不像Laravel 5.5那样有效。如何在Laravel 5.5上自定义电子邮件模板?
答案 0 :(得分:0)
将供应商刀片文件发布到resources/views/vendor
目录后,您可以在email.blade.php
目录下编辑resources/views/vendor/notifications
:
php artisan vendor:publish
或者您可以通过在用户模型中重写sendPasswordResetNotification
方法来完全覆盖重置通知:
/**
* Send the password reset notification.
*
* @param string $token
* @return void
*/
public function sendPasswordResetNotification($token)
{
$this->notify(new ResetPasswordNotification($token));
}
答案 1 :(得分:-1)
您将供应商刀片email.blade.php
文件发布到resources/views/vendor/notifications
,您使用:
$php artisan vendor:publish
编辑文件以自定义布局电子邮件模板后。
继续,在sendPasswordResetNotification
模型中覆盖函数User
/**
* Send the password reset notification.
*
* @param string $token
* @return void
*/
public function sendPasswordResetNotification($token)
{
$this->notify(new ResetPasswordNotification($token));
}
使用ResetPasswordNotification
,您可以在ResetPasswordNotification
中创建app\Notifications
。内容与文件Illuminate\Auth\Notifications\ResetPassword
的内容相同:
/**
* Build the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->line('You are receiving this email because we received a password reset request for your account.')
->action('Reset Password', url(config('app.url').route('password.reset', $this->token, false)))
->line('If you did not request a password reset, no further action is required.');
}