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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With