Javatpoint Logo
Javatpoint Logo

Laravel 5.8 Email Verification Example

In this section, we are going to learn about email verification in Laravel 5.8. We will see the setup of email verification of the registered user. When the new user wants to login into Laravel 5.8, they should first verify their email address. In order to verify the email address in Laravel, an activation code will be sent to the registered email address.

In the old version of Laravel, we have to manually do the process of email verification, but Laravel 5.8 version gives us an in-build setup of email verification. In this version, the new users will proceed when they have complemented the verification of their email addresses. For this, we have to do some basic setup by using the mail configuration, routes, and middleware. The basic steps to perform email verification are described as follows:

Step 1:

In this step, we are going to Install Laravel 5.8. For this, we will download the latest fresh Laravel 5.8 version. We will run the following command by opening our command prompt or terminal.

Step 2:

In this step, we are going to do Database Configuration. For this, we will use the .env file and add the details of database configuration into it. So we will create the username, password, etc. Like this:

.env:

When we completed the addition of database configuration, we will use the below command to run the default migration of Laravel like this:

Step 3:

In this step, we are going to do Email Configuration. For this, we will use the .env file. When the user completed the user registration, we will send an email. We need to add the details of SMTP to send the email like this:

.env:

Step 4:

In this step, we will Create Auth. Forget password, registration, and login can be quickly created with routes by using Laravel. We will use auth command to create these, which is described as follows: 

Step 5:

In this step, we will do Email Verification Setup. We will use a user model to implement the email verification class. We will also provide protection by using the middleware. So we will update the following files just like shown below one by one.

app/User.php:

routes/web.php:

app/Http/Controllers/HomeController.php

Now our above code is ready to run. In order to run the above code, we will use the following command:

When we run this command, the following output will be generated:

Laravel 5.8 Email Verification Example

Registration:

Laravel 5.8 Email Verification Example

Email Alert:

Laravel 5.8 Email Verification Example

Email:

Laravel 5.8 Email Verification Example

Success:

Laravel 5.8 Email Verification Example





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA