Use a custom email template blade file for your Laravel password reset email with just 6 lines of code.
Open app/Providers/AuthServiceProvider.php
in the boot()
function paste and edit the following:
ResetPassword::toMailUsing(function ($notifiable, $token) { $url = route('password.reset',$token).'?email='.$notifiable->getEmailForPasswordReset(); return (new MailMessage()) ->subject('Password reset') ->view('emails.reset', compact('url')); });
This overrides the reset password email notification to then build your own email as per the parameters.
I will be using a custom email template saved in /resources/views/emails/verify.blade.php
and the most important part is passing in the reset URL which is a generated token to safely reset the password.
route('password.reset',$token)
is the password reset route with the reset token appended.
.'?email='.$notifiable->getEmailForPasswordReset()
is the account email attached to the URL as a parameter. This part is optional however if it is present then the email input field automatically gets filled.
The URL will look like this:
https://domain.com/password/reset/7f0dfc998d5cbd0gf85834e940e3061d0db4a56ehcfd71c09fdeec0c0f7fcf9f?email=email@somemail.com
Ensure that your email template blade file uses this $url
variable in a button or link.