Skip to content
logo1

Appfinz Tech Blogs

Javascript, Laravel, Jquery, Vue Js, Node Js Blogs

Primary Menu logo1

Appfinz Tech Blogs

  • PHP
  • Laravel
  • React
  • React Native
  • Payment Gateway
  • Javascript
  • Jquery
  • Shopify
  • WordPress
  • Angular JS
  • Vue JS
  • Website Trends
  • SEO
  • Node JS
  • Home
  • PHP
  • How to make Email Verifications in Laravel
  • PHP

How to make Email Verifications in Laravel

10 months ago
How to Verify Email Using Laravel, Email Verification Method in Laravel

Loading

Hello Artisans, In this blog we will see how to implement Email Verifications in Laravel, How Email Verification works with Laravel Application, We will use laravel Breeze package to implement Email Verifications in Laravel Application, To implement email verification in Laravel, follow these steps:

Step 1: Set Up Your Laravel Project

If you don’t have a Laravel project yet, create one:

composer create-project --prefer-dist laravel/laravel laravel-email-verification

Step 2: Set Up Authentication

Install Laravel Breeze or Laravel Jetstream for authentication scaffolding. Here, we’ll use Laravel Breeze:

composer require laravel/breeze --dev
php artisan breeze:install
php artisan migrate
npm install && npm run dev

Step 3: Configure Email Settings

Set up your email configuration in the .env file. Add your SMTP server details:

MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=your_username
MAIL_PASSWORD=your_password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=noreply@example.com
MAIL_FROM_NAME="${APP_NAME}"

Step 4: Enable Email Verification

In your User model (app/Models/User.php), make sure the MustVerifyEmail interface is implemented:

use Illuminate\Contracts\Auth\MustVerifyEmail;

class User extends Authenticatable implements MustVerifyEmail
{
    // other model methods and properties
}

Step 5: Update Auth Routes

In routes/web.php, add the following route to handle email verification:

use Illuminate\Foundation\Auth\EmailVerificationRequest;
use Illuminate\Http\Request;

Route::get('/email/verify', function () {
    return view('auth.verify-email');
})->middleware('auth')->name('verification.notice');

Route::get('/email/verify/{id}/{hash}', function (EmailVerificationRequest $request) {
    $request->fulfill();

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

Route::post('/email/verification-notification', function (Request $request) {
    $request->user()->sendEmailVerificationNotification();

    return back()->with('message', 'Verification link sent!');
})->middleware(['auth', 'throttle:6,1'])->name('verification.send');

Step 6: Create Email Verification View

Create a new view file for the email verification notice at resources/views/auth/verify-email.blade.php:

@extends('layouts.app')

@section('content')
<div>
    @if (session('message'))
        <div>
            {{ session('message') }}
        </div>
    @endif

    <div>
        Before proceeding, please check your email for a verification link.
        If you did not receive the email, click the button below to request another.
    </div>

    <form method="POST" action="{{ route('verification.send') }}">
        @csrf
        <button type="submit">Resend Verification Email</button>
    </form>
</div>
@endsection

Step 7: Modify Registration Controller

Make sure your registration controller sends a verification email after a user registers. In the RegisteredUserController (or wherever your registration logic is):

use Illuminate\Auth\Events\Registered;

public function store(Request $request)
{
    // validate and create user
    $user = User::create([
        'name' => $request->name,
        'email' => $request->email,
        'password' => Hash::make($request->password),
    ]);

    event(new Registered($user));

    Auth::login($user);

    return redirect()->route('verification.notice');
}

Step 8: Protect Routes

Ensure that your application routes are protected and only accessible to verified users. Use the verified middleware in routes/web.php:

Route::get('/home', [HomeController::class, 'index'])->middleware(['auth', 'verified'])->name('home');

Step 9: Test Email Verification

  1. Register a new user through your registration form.
  2. Check the registered user’s email for the verification link.
  3. Click the verification link to verify the email.
  4. Ensure the user is redirected to the intended page after verification.

I hope this blog will help you to build Make Email Verifications in Laravel

Also Read:

User Login with API Using Laravel 11

solve 500 internal server error in laravel

Paypal Payment Gateway Integration in Laravel 11

Laravel 9 Contact Form Example Tutorial

Laravel Middleware for Auth Admin Users Roles

If youโ€™re planning to revamp your online presence, donโ€™t miss exploring ourย website designing servicesย and customย website developmentย solutions tailored to your business needs.

About Post Author

Kishan Kumar || Founder @ Appfinz

administrator

๐—ฆ๐—ต๐—ผ๐—ฝ๐—ถ๐—ณ๐˜† ๐—ฃ๐—น๐˜‚๐˜€ ๐—˜๐˜…๐—ฝ๐—ฒ๐—ฟ๐˜ | Digital Marketing Consultant (Organic & Paid Outreach) | Built ๐—”๐—ฝ๐—ฝ๐—ณ๐—ถ๐—ป๐˜‡ ๐—ง๐—ฒ๐—ฐ๐—ต๐—ป๐—ผ๐—น๐—ผ๐—ด๐—ถ๐—ฒ๐˜€ | Working with Graphics, Website & Performance Marketing Enthusiasts.
Ask for ๐–๐ž๐›๐ฌ๐ข๐ญ๐ž ๐ƒ๐ž๐ฏ๐ž๐ฅ๐จ๐ฉ๐ฆ๐ž๐ง๐ญ | ๐’๐จ๐œ๐ข๐š๐ฅ ๐Œ๐ž๐๐ข๐š ๐Ž๐ฎ๐ญ๐ซ๐ž๐š๐œ๐ก | ๐†๐จ๐จ๐ ๐ฅ๐ž ๐‚๐š๐ฆ๐ฉ๐š๐ข๐ ๐ง๐ฌ | ๐‹๐š๐ซ๐š๐ฏ๐ž๐ฅ & ๐’๐ก๐จ๐ฉ๐ข๐Ÿ๐ฒ ๐ƒ๐ž๐ฏ๐ž๐ฅ๐จ๐ฉ๐ฆ๐ž๐ง๐ญ

See author's posts

Tags: Email Verification Method in Laravel, Email Verifications in Laravel, How to integrate email verification method in laravel, Laravel Email Verification

Continue Reading

Previous User Login with API Using Laravel 11
Next Building a Simple AJAX CRUD Application in Laravel: Add, Edit, Delete, and List

Please Support us

If our blogs help you to solve your problem, you can help us running this blogs by paying for a small coffee brew.

Google Pay/Phonepe/Paytm Number: +91 8340725097

If my blogs help you to find your answer and query, then help us with above mentioned links

React JS

  • React
  • React Native

Difference Between Ionic React Vs React Native

5 years ago
  • React
  • React Native

What is the difference between React Native and React?

5 years ago

Laravel

  • Laravel
  • PHP

Building a Simple AJAX CRUD Application in Laravel: Add, Edit, Delete, and List

10 months ago
  • Laravel

Laravel Custom Authentication | Registration, Login, Logout Process | Laravel login with session

10 months ago
  • Laravel

How to change Password in Laravel Using Tinker Method

10 months ago
  • Laravel
  • PHP

User Login with API Using Laravel 11

10 months ago
  • Laravel

What’s the differences between PUT and PATCH? in laravel

11 months ago

Recent Blogs

  • Social Media

The upsurge of niche social media platforms and what that means for your brand

4 years ago
  • PHP

WordPress Hooks and Filter | Complete Overview of WordPress hooks

4 weeks ago
  • Marketing
  • SEO

What are the 7 Ps of Marketing?

8 months ago
  • PHP

What is Fetch PHP? How to use it inside PHP

8 months ago
  • Laravel
  • PHP

Building a Simple AJAX CRUD Application in Laravel: Add, Edit, Delete, and List

10 months ago
  • Laravel

Laravel Custom Authentication | Registration, Login, Logout Process | Laravel login with session

10 months ago

Appfinz Technologies

Appfinz Technologies has been in the industry for more than 12 years, holding a core motive to make a change in the world by providing solutions perfectly crafted with intelligence and creativity. the company is gradually yet constantly spreading its legs across the world leaving the rat race for the rest and striving to become better than the best!

Our services

  • Shopify Development Company
  • SEO Services In India
  • SEO Packages
  • Digital Marketing Packages
  • Social Media Marketing

Categories

Angular JS Artificial Intelligence Ionic Framework Javascript Jquery Laravel Marketing Node JS Payment Gateway PHP Python React React Native SEO Shopify Social Media VPN Vue JS Website Trends Wordpress
  • Home
  • Instagram
  • Facebook
  • Twitter
  • Linkedin
  • Github
ยฉ Appfinz Technologies | All rights reserved.