Laravel Email Verification for Beginners (A Kid-Friendly Guide!)

Hey Laravel enthusiasts!

Now you have learned to build a Laravel app where users can register and log in. What happens if someone registers with a fake email? It is the situation where email verification comes in.

It’s like this:

“If the attachment is really your email, click the magic link I just sent you.”

Let’s make it happen in Laravel 12.x — step by step, without any stress! 

Step 1: Set Up a Fresh Laravel Project

Still haven’t started yet; let’s spin up a new Laravel app:

bash

composer create-project laravel/laravel email-verification-app

cd email-verification-app

php artisan serve

Step 2: Add Auth Scaffolding

Let’s include login and registration pages using Laravel UI:

bash

composer require laravel/ui

php artisan ui bootstrap --auth

npm install && npm run dev

 

Run your migrations:

 

bash

php artisan migrate

 

Now go to http://localhost:8000/register — and boom! You can register.

Step 3: Enable Email Verification

In your User model (app/Models/User.php), do this:

Implement the interface:

php

use Illuminate\Contracts\Auth\MustVerifyEmail;

 

class User extends Authenticatable implements MustVerifyEmail

Update your route file

In routes/web.php, wrap the home or dashboard route with verified middleware:

 

php

Route::get('/home', function () {

    return view('home');

})->middleware(['auth', 'verified']);

 

Means: Users with verified emails only can see this page.

Step 4: Set Up Email Sending

Laravel needs to send real emails to verify accounts.

In the .env file, add something like this:

 

env

MAIL_MAILER=smtp

MAIL_HOST=smtp.mailtrap.io

MAIL_PORT=2525

MAIL_USERNAME=your_username_here

MAIL_PASSWORD=your_password_here

MAIL_ENCRYPTION=null

MAIL_FROM_ADDRESS=hello@example.com

MAIL_FROM_NAME="Your App Name"

 

Tip: Use Mailtrap.io for testing. It is free of cost and appropriate for beginners!

Step 5: Try It Out!

Now register a user. After you sign up:

Laravel automatically sends a verification email
The user sees a message like “Please verify your email.”
When the user clicks the link — BOOM! They’re verified!

Try visiting /home before clicking the link. You’ll get stopped. Laravel protects the route with the verified middleware.

 

Read More Blogs:

Laravel Password Reset for Beginners

Step-by-Step Guide to Mastering Laravel Authorization

Laravel 12 Import and Export CSV and Excel File

 

Step 6: Resend the Email

What will happen if the user doesn’t get the email? Laravel has a built-in way to resend the verification link!

When the user is logged in but not verified, Laravel shows a view called

 

bash

resources/views/auth/verify.blade.php

 

That page already has a form to resend the email; no need to build it from scratch. Isn’t it amazing!

 

Laravel Email Verification steps

 

Extra: Show a Message in Blade

Would you like to display something exclusively to verified users? Little tricks for using Blade:

blade

@if (Auth::user()->hasVerifiedEmail())

    <p>Thanks for verifying your email!</p>

@else

    <p>Please check your inbox to verify your email.</p>

@endif

 

Simple and excellent!

What Did You Learn?

Email verification keeps your app safe
Laravel has it built-in and its super easy
You can protect routes using verified middleware
Laravel even resends the verification link automatically

Final Thoughts

You’re now a Laravel email verification pro! 

What you can try next is written below:

  • Customize the email message
  • Redirect users after verifying
  • Block access to certain pages unless verified

Laravel makes serious stuff feel like child’s play.