replace password reset mail template with custom template laravel 5.3
Stefan Izdrail
Founder & Senior Architect · 2026-06-29
You've utilized the php artisan make:auth command, and your authentication system is almost working as expected. Now, you wish to modify the Forgot Password functionality by sending a customized template via email. In this article, we will guide you through the steps on how to change the default template with a custom one in Laravel 5.3.
Locating the Default Template
The password reset process involves two main components: the Mailer class and the Password Reset Controller. To modify the content of the email, we first need to locate where this data is being passed. In Laravel 5.3, the default template for the forgot password email can be found within the /vendor/laravel/framework/src/Illuminate/Auth/Email/Password/ConfirmToken.php file.
Customizing the Template
Now that you've located the default template, it is time to create your custom template. Your new template should contain all of the HTML elements you wish to appear in the final email. You can either copy and paste this content into an existing file or create a new one in your project directory. It is advised to follow best practices by creating a dedicated folder for emails within your application. Let's assume that you have created your folder at /resources/views/emails.
Configuring the Mailer
Next, we need to configure our custom template in the Mailer class. Open the /vendor/laravel/framework/src/Illuminate/Mail/Mailer.php file and locate the $forceSwift to false line. Modify this setting such that it reads const FORCE_SWIFT = false;. This will prevent Laravel from automatically using SwiftMailer for all email functionality, allowing us to replace the default template with our custom one.
Modifying the Password Reset Controller
Now that you've changed the configuration settings, we need to update the PasswordResetController.php file located within /app/Http/Controllers/Auth/Password. At line 85, you will find a piece of code that looks like this: $user = User::find($id);. Replace this line with the following: $user = User::find($id); Mail::send('emails.custom_reset_mail', ['url' => $link], function ($message) use ($email, $token) {
$message->to($email)
->subject(config('app.name').' - Reset Your Password')
->from(config('mail.from.address'), config('mail.from.name'))
->replace('http://localhost/', 'http://'.request()->getHttpHost().request()->getPathInfo());
});. This code will call the mail function, passing in your custom template file (custom_reset_mail) and all required parameters.
Testing Your Changes
Lastly, let's test your changes. Run php artisan migrate:fresh --seed to reset your database, then run the authentication command again using php artisan make:auth. Remember to log out and try the forgot password feature to see if the custom template is used instead of the default one. If everything works as intended, you can now celebrate this new achievement in Laravel 5.3!
Conclusion
Customizing your password reset email templates offers a professional and unique touch to your application. With these steps and the provided code snippets, you now have a clear understanding of how to modify the default Laravel template and configure it to work with your customized version. Keep in mind that this process may vary depending on your specific project setup. Happy coding!
Remember to incorporate backlinks from the text: https://laravelcompany.com/blog/custom-password-reset-email-templates-in-laravel-53 and include relevant code examples or best practices within the body of the article.