Customizing the Password Reset Email in Laravel

LaravelPosted on

Laravel brings a nice password reset feature by default. We can easily customize the email that is going to be sent to the user, let’ see how!

The Password Reset Email

Possibly everyone used the password reset feature in Laravel, even those who just tried it for a short time. We won’t go in the “how to reset” topic, but if you want to read a bit more, you can dig deeper into the documentation.

Since it’s a core feature, we don’t have any view or notification that we can customize, so the question is how can we make our own password reset notification that we want to send to the user. Do we need to customize a view or a Mail class?

Customizing the Password Reset Notification

Since the User model uses a Notifiable trait, it’s convenient to use a notification to send the password reset email. According to the documentation, the only thing we need to do is to implement a method on the User model and override the default features.

 * Send the password reset notification.
 * @param  string  $token
 * @return void
public function sendPasswordResetNotification($token)
    $this->notify(new CustomResetPasswordNotification($token));

As we can see, all we need to do to generate the custom notification that we want to use to notify the user. We can do that by running the php artisan make:notification CustomResetPasswordNotification command.

Now, we can customize the notification as we want. Notifications have their own documentation, so all we need to do is to follow the docs and prepare the unique and customized content we want to send to the user, who lost its password.

Need a web developer? Maybe we can help, get in touch!

Similar Posts

More content in Laravel category