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:
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.
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:
When we completed the addition of database configuration, we will use the below command to run the default migration of Laravel like this:
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:
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:
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.
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: