In this tutorial, we will see how we can create a reset or forgot password system in laravel 9 application. To create this send reset password link email laravel, we will use laravel default authentication system, and then we will use laravel default password reset mechanism. For this, we will use the default User model and users table to send reset password token.

You know that Laravel provides this default reset password system with email-based token system. Laravel also provides laravel reset password link expiration and which is 60 minutes by default. We can change this laravel reset password link expiration time also. So let's see hopw we can create laravel 9 forgot password example.

Login page with for your password link

laravel-auth-reset-password-example

 

Forgot password form

laravel-reset-password-example-verification-email-page

After submitting forgot password form

laravel-forgot-and-reset-password-example

 

Reset password email

laravel-reset-password-email

After clicking the reset password button from mail

final-reset-password-form-laravel

Step 1: Install Laravel

First of all, we need to get a fresh Laravel 9 version application using the bellow command, So open your terminal OR command prompt and run the bellow command to start send reset password link email laravel.

composer create-project laravel/laravel example-app

 

Read also: Laravel Passwordless Login | Login With Username In Laravel

 

Step 2: Connect Database

We need registration, so need database table to save user data. We will open the ".env" file and change the database name, username and password in the env file and create send reset password link email laravel 9.

.env

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=Enter_Your_Database_Name
DB_USERNAME=Enter_Your_Database_Username
DB_PASSWORD=Enter_Your_Database_Password

 

Now you have to run this migration by following the command:

php artisan migrate

 

Step 3: Create Auth Scaffold

Here, we will use laravel ui package and create auth scaffold with the bootstrap framework. let's follow bellow command:

composer require laravel/ui

 

Now create a simple bootstrap auth system:

php artisan ui bootstrap --auth

 

And run npm i and npm run dev to compile javascript assets.

 

Step 4: Configure Mail

To receive forgot or reset password mail, I am going to use mailtrap. So configure it like:

.env

MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=bcca41cf7e855f
MAIL_PASSWORD=c1abf4f6f9596d
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="no-reply@laravelia.com"
MAIL_FROM_NAME="${APP_NAME}"

 

Now all are set to go to check the laravel reset password email template. So now you can test your app to check laravel 9 reset password. Hope it will help you.

Now you can test our application by visiting the below URL:

URL
http://127.0.0.1:8000/password/reset

 

Read also: Laravel 9 Auth Email Verification With Activation Link

 

Conclusion

Now we know laravel 9 forgot password. Hope this send reset password link email laravel 9 tutorial will help you to create laravel reset password email template.

Category : #laravel

Tags : #laravel , #laravel auth