一、将邮件模板复制出来
通过以下代码,将
\vendor\laravel\framework\src\Illuminate\Mail\resources\views
里面的内容,复制到
\resources\views\vendor\mail
php artisan vendor:publish --tag=laravel-mail
通过以下代码,将
\vendor\laravel\framework\src\Illuminate\Notifications\resources\views
里面的内容,复制到
\resources\views\vendor\notifications
php artisan vendor:publish --tag=laravel-notifications
app/http/Notifications/创建CustomResetPasswordNotification.php
<?php
namespace App\Notifications;
use Illuminate\Auth\Notifications\ResetPassword as ResetPasswordBase;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Facades\Lang;
class CustomResetPasswordNotification extends ResetPasswordBase
{
public function toMail($notifiable)
{
if (static::$toMailCallback) {
return call_user_func(static::$toMailCallback, $notifiable, $this->token);
}
$url = $this->resetUrl($notifiable);
return (new MailMessage)
->subject(Lang::get('auth.Verify Email Address'))
->line(Lang::get('auth.Please click the button below to verify your email address.'))
->action(Lang::get('auth.Verify Email Address'), $url)
->line(Lang::get('auth.If you did not create an account, no further action is required.'));
}
}
app/models/user.php修改
use App\Notifications\CustomResetPasswordNotification; // 引入你自定义的通知类
/**
* 发送电子邮件验证通知。
*
* @param string $token
* @return void
*/
public function sendPasswordResetNotification($token)
{
$this->notify(new CustomResetPasswordNotification($token));
}
重定了原来的发送邮件函数,走去了新建立的这个notification。