[Laravel 5.3.6] How To Replace Password Reset Mail with Custom Mailable Template?
Hi,
I am using Laravel 5.3.6 and using the out of the box user authentication using "make:auth".
My question: How to replace default password reset mail template with custom created Mailable template?
I thought of overriding the method in "Illuminate\Foundation\Auth\SendsPasswordResetEmails" in my "ForgotPasswordController.php"
public function sendResetLinkEmail(Request $request)
{
$this->validate($request, ['email' => 'required|email']);
// We will send the password reset link to this user. Once we have attempted
// to send the link, we will examine the response then see the message we
// need to show to the user. Finally, we'll send out a proper response.
$response = $this->broker()->sendResetLink(
$request->only('email'), $this->resetNotifier()
);
if ($response === Password::RESET_LINK_SENT) {
return back()->with('status', trans($response));
}
// If an error was returned by the password broker, we will get this message
// translated so we can notify a user of the problem. We'll redirect back
// to where the users came from so they can attempt this process again.
return back()->withErrors(
['email' => trans($response)]
);
}
But it is deeply linked with other traits, brokers, which validates and checks for common errors and db look up already.
If I am to override this method,I have to bypass all these goodies and implement my own validations.
Any suggestion on how to just replace the custom mail template with default one? I am not sure how that mail template is generated. Its not under any view.
Thanks!
This lessen gave me some hints.
https://laracasts.com/series/whats-new-in-laravel-5-3/episodes/9
I think I will be switiching to 'Notifications' for all user account related mail system.
Basically I can just do this:
php artisan vendor:publish
This will publish the
\vendor\laravel\framework\src\Illuminate\Notifications\resources\views
To
\resources\views\vendor\notifications
.
.
.
plus pagination
At this point I can just customize the email template to my branding needs.
In my case I have extra feature to verify user account after they register, so I can use the Notification:Email channel to send that mail.
May be for other mailing needs I can use the Mailable (like newsletters etc.)
Please or to participate in this conversation.