Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Unik's avatar
Level 1

Laravel 7 how to replace password reset mail template

How can I replace the Password reset Mail template on Laravel 7, i have try the following things on this link: https://stackoverflow.com/questions/41400395/replace-password-reset-mail-template-with-custom-template-laravel-5-3/41401524#41401524 but this was for Laravel 5.3 and not working to me on Laravel 7.

0 likes
9 replies
fylzero's avatar
fylzero
Best Answer
Level 67

@unik

Do this...

Add this to your User model...

use App\Notifications\ResetPasswordNotification; // At the top under your namespace

public function sendPasswordResetNotification($token)
{
    $this->notify(new ResetPasswordNotification($token));
}

Note: You're doing this to override User > Authenticable > CanResetPassword > sendPasswordResetNotification

Create a new notification...

php artisan make:notification ResetPasswordNotification

Open app/Notifications/ResetPasswordNotification.php

There you can modify your email. If you want to copy off the original, look in vendor/laravel/framework/src/Illuminate/Auth/Notifications/ResetPassword.php.

Do NOT modify "core" aka vendor folder code to do this. Everything can be extracted to your app folder. What this article is suggesting to do is a rookie mistake.

6 likes
zainshabir00's avatar

@fylzero In the action, I have this url url('password/reset', $this->token), it only returns reset url with token, how can i add email to this?

God_WIn's avatar

@zainshabir00 You need to pass it from the controller you are calling the job and then initialise it in the constructor then you can use it in the function.

Unik's avatar
Level 1

Thanks a lot for this good Answer, cann you also say me which part do I copy from the vendor/laravel/framework/src/Illuminate/Auth/Notifications/ResetPassword.php. to my Notification thats do the link to work because my Notification is giving a link that are giving only localhost:8000. See that Messag down.

If you’re having trouble clicking the "Notification Action" button, copy and paste the URL below into your web browser: http://localhost:8000.

fylzero's avatar

@unik If you wanted, you could just copy everything in that file and paste it in your new notification file. Just be sure to update the namespace to App\Notifications\ResetPasswordNotification and change the class name to ResetPasswordNotification, then you can modify from there.

pappupasshogaya's avatar

@fylzero , @unik , @zainshabir00 I need your help, kindly suggest me how can I change the ResetPassword email's html template (look & feel), not content/text of email? Look forward to hear you. Thanks.

pappupasshogaya's avatar

I found the solution, using Mail facade in User model..

use Illuminate\Support\Facades\Mail;

add below function in User model:

public function sendPasswordResetNotification($token){ // $this->notify(new MyCustomResetPasswordNotification($token)); <--- remove this line, use Mail instead like below:

$data = [ $this->email ]; Mail::send('email.reset-password', [ 'name' => $this->name, 'reset_url' => route('password.reset', ['token' => $token, 'email' => $this->email]), ], function($message) use($data){ $message->subject('Reset Password Request'); $message->to($data[0]); }); }

here 'email.reset-password' means email is a folder in views folder and reset-password.blade.php is email template. Thanks for asking this question.

Abnormal's avatar

TLDR: Use laravel's method of exporting templates to modify look and feel to every notification for Laravel 6 and up.

I was also looking to figure out how to correctly implement a custom HTML template for emails and I ran across some documentation for the most recent version of Laravel that appears to work. Note: this doesn't require custom code in the user model. This publishes the vendor template to the app folder for that you can now modify for ALL of your notification needs that utilize that vendor. I have yet to implement a custom message which I will try next but this is how you get the template out.

laravel.com/docs/9.x/notifications#customizing-the-components

It won't let me link to Laravel's documentation

php artisan vendor:publish --tag=laravel-mail

This puts everything you need into app/resources/views/vendor/mail/ It will contain the HTML and text templates that change the look and feel. Posting this for those that are looking for the laravel documented way of doing this. For changing the messaging you will have to likely follow @fylzero's approach to implementation.

This is not to say that @pappupasshogaya's approach is wrong, it just lets you modify the template without implementing custom notification instrumentation in the User model and lets you apply say logo changes to every notification.

Please or to participate in this conversation.