Laravel Email Address Verification with Example

Hello artisans, today I’ll talk about how you can enable email verification on our application. Email verification is one of the basic requirements of most applications. Laravel provides an easy way to implement this feature. So, no more talk and dive into the topic.

Note: Tested on Laravel 8.65.

Table of Contents

  1. Install Laravel and Basic Config
  2. Setup Model
  3. Prepare routes
  4. Prepare Controller
  5. Prepare blade
  6. Setup Email Credential

Install Laravel and Basic Config

Each Laravel project needs this thing. For that you can see the very beautiful article on this topic from here: Install Laravel and Basic Configurations.

Setup Model

Open your User.php and paste the following code


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;
use Laravel\Sanctum\HasApiTokens;

class User extends Authenticatable implements MustVerifyEmail
    use HasApiTokens, HasFactory, Notifiable;

    protected $fillable = [

    protected $hidden = [

    protected $casts = [
        'email_verified_at' => 'datetime',

Prepare Routes

Open your web.php and paste the following code


use Illuminate\Foundation\Auth\EmailVerificationRequest;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;

Route::get('/', function () {
    return view('welcome');

Route::get('/email/verify', function () {
    return view('auth.verify');
Route::get('/email/verify/{id}/{hash}', function (EmailVerificationRequest $request) {

    return redirect('/home');
})->middleware(['auth', 'signed'])->name('verification.verify');


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

Prepare Controller

Open your HomeController.php and paste the following code


namespace App\Http\Controllers;

use Illuminate\Http\Request;

class HomeController extends Controller

    public function __construct()

    public function index()
        return view('home');

Prepare Controller

Open your verify.blade.php and paste the following code


<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">{{ __('Verify Your Email Address') }}</div>

                <div class="card-body">
                    @if (session('resent'))
                        <div class="alert alert-success" role="alert">
                            {{ __('A fresh verification link has been sent to your email address.') }}

                    {{ __('Before proceeding, please check your email for a verification link.') }}

Setup Email Credential

For email we have used Mailtrap, you can easily open an account and get credential form here.

Mailtrap configuration

Click on to show credential and update your .env file

[email protected]

And that’s it you have implemented email verification on your application

That’s all. You can download this project from GitHub. Thanks for reading.