Laravel 8 Custom Email Verification Tutorial

Websolutionstuff | Dec-29-2021 | Categories : Laravel PHP

In this article, we will see an example of laravel 8 custom email verification. Many web applications require users to verify their email addresses before using the application. Laravel provides convenient built-in services for sending and verifying email verification requests.

So,I will give you an example of custom email verification in laravel 8 or laravel 8 auth verify email. For custom email verification we need some basic requirements like middleware, routes and mail configuration.

Let's see the laravel 8 custom email verification tutorial.

Step 1 : Create Laravel 8 Application

In this step, we will create a new laravel 8 project using the below command.

composer create-project --prefer-dist laravel/laravel laravel_custom_email_verification



Step 2 : Configuration Database

Now, we will configure a database in the .env file.

DB_PORT = 3306
DB_DATABASE = Your_database_name
DB_USERNAME = Your_database_username
DB_PASSWORD = Your_database_password

After adding database configuration. After running the default migrations of laravel using the below command.

php artisan migrate


Step 3 : Email Configuration for .env

After the database migrates we will set up email configuration in the .env file.

MAIL_PASSWORD = Your_Password



Step 4: Install Auth

In this step, install laravel/ui package for basic UI using the below command.

composer require laravel/ui

After installing laravel/ui we will install bootstrap auth using the below command for basic login, registration. After that install NPM and run NPM in your project.

php artisan ui bootstrap --auth

Install NPM :

npm install

Run NPM :

npm run dev


Step 5 : Setup Email Verification

Now, we will set up email verification on the user.php file. So, in the User model add an email verification class and use middleware for protection. In the User model, you want need to add MustVerifyEmail Auth and implements MustVerifyEmail on the User class.



namespace App\Models;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable implements MustVerifyEmail
    use HasFactory, Notifiable;

     * The attributes that are mass assignable.
     * @var array
    protected $fillable = [

     * The attributes that should be hidden for arrays.
     * @var array
    protected $hidden = [

     * The attributes that should be cast to native types.
     * @var array
    protected $casts = [
        'email_verified_at' => 'datetime',




Auth::routes(['verify' => true]);

Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');




namespace App\Http\Controllers;

use Illuminate\Http\Request;

class HomeController extends Controller
     * Create a new controller instance.
     * @return void
    public function __construct()

     * Show the application dashboard.
     * @return \Illuminate\Contracts\Support\Renderable
    public function index()
        return view('home');


You might also like :

Recommended Post
Featured Post
Laravel 9 Multiple Authentication Using Middleware
Laravel 9 Multiple Authenticat...

In this article, we will see laravel 9 multiple authentications using middleware. Using middleware we authenticate the u...

Read More


How To Validate Email Using jQuery
How To Validate Email Using jQ...

In this article, we will see how to validate email using jquery. we will use regular expression(regex) for email va...

Read More


Laravel 9 Cron Job Task Scheduling Tutorial
Laravel 9 Cron Job Task Schedu...

In this article, we will see laravel 9 cron job task scheduling tutorial, many times we require to run some piece o...

Read More


How To Get Current Date And Time In Node.js
How To Get Current Date And Ti...

In this example we will see how to get current date and time in Node.js application. In Node.js date and time are handle...

Read More