Laravel 7/6 Email Verification Example | Laravel Signup Verification Link to Email with Example
In this article we will how can Laravel send email verification after registration with example . For this example we will Mailtrap.io for verification . Let me tell you first that it's very easy to do email verification with Laravel , you just need to do some following changes on your project .
After registration it will send a verification email to your corresponding registration email and it will show a message that " Before proceeding, please check your email for a verification link. If you did not receive the email " since you have not verify your email .
Let's see the steps for Laravel Email Verification ..
Step-1 : Setup your Laravel Project :
Firstly Download your Laravel project and setup the authentication for your project which is already provided by Laravel . Use the following commands to create a Laravel project and implementing Login and Signup authentication in itcomposer create-project --prefer-dist laravel/laravel project-name cd project-name composer require laravel/ui php artisan ui vue --auth npm install
After that setup your database in your project .
Step-2 : Setting up Mail Configuration ( Mailtrap ) :
The next step is to setup Mail credential on Mailtrap.io in your Laravel project . Make the following mail configuration on your projects ' .env ' file according to your mailtrap credential as shown below . For detail information you can also read Laravel 7 Authentication .
Mailtrap credentials :
Project-name\.env.php :
MAIL_MAILER=smtp MAIL_HOST=smtp.mailtrap.io MAIL_PORT=2525 MAIL_USERNAME=34d7af640c9818 MAIL_PASSWORD=d07708a6993e38 MAIL_ENCRYPTION=tls MAIL_FROM_ADDRESS=0e3aa00606-f48da0@inbox.mailtrap.io MAIL_FROM_NAME="${APP_NAME}"
Step-3 : Make following change on your file :
Project-name\app\User.php :
On User.php implement the following classclass User extends Authenticatable implements MustVerifyEmail
Project-name\routes\web.php :
In web.php make the following changesAuth::routes(['verify'=>true]);
Route::get('/home', 'HomeController@index')->name('home')->middleware('verified');
Step-4 : Final Step :
Now use the following command on your terminal otherwise it might show you an error " cannot send message without a sender address " .
php artisan config:cache
This is it now your project is ready for mail verification .Now on new Signup / Registration it will send you a verification message on your mailtrap id like the following .
You have to verify your mail in order to login . So this article is all about how can you send verification email on Signup / Registration . Hope this article will helpful to you .
Thank you for reading this article 😊
For any query do not hesitate to comment below 💬
Also Read :-
Why Laravel is so Popular ?
Add Date-Time Picker in Laravel
How to use Laravel Authentication
How to make Covid-19 Tracker
How to use Laravel SweetAlert
How to use Pagination in Laravel
How to use Vue JS in Laravel