Laravel 5.7 Email Verification Example Tutorial

Laravel 5.7 Email Verification Example Tutorial is the topic, we will discuss today. Laravel is not only a PHP framework, today its know as a new trend of PHP Web Development. Freshly Laravel 5.7 is released with some of the new features, which make development more simple and flexible. Laravel 5.7 provides a new feature called email verification. In this article, we will discuss “Email Verification Laravel 5.7 New Feature”. Lots of website or web applications ask users to verify the email addresses before using the website or applications. Laravel 5.7 makes email verification easy, you don’t want to recreate all the functionality.

Laravel 5.7 Email Verification Example Tutorial

We are going to Configure Laravel Project.

#1: Install Laravel 5.7 Project

composer create-project --prefer-dist laravel/laravel laravel5.7emailverification

#2: Configure SQL Database

Now we can setup database credentials.



Now, migrate table by the following command.

php artisan migrate

Now, you can see the users table and there is one extra field called email_verified_at.

laravel email verification example

#3: Create Auth Scaffolding

Now move to the terminal and type the following command.

php artisan make:auth

This command has generated one extra view file called verify.blade.php. This file is located in resources/views/auth/verify.blade.php. It is new in Laravel 5.7 as the verification functionality is implemented in this version.

<!--verify.blade.php -->


<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.') }}
                    {{ __('If you did not receive the email') }}, <a href="{{ route('verification.resend') }}">{{ __('click here to request another') }}</a>.

#4: Add a mustVerify interface in the User model

In a User.php model, you can see extra contract added called  MustVerifyEmail. To use this email verification process, we want to implement this contract.



namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements MustVerifyEmail
    use Notifiable;

     * The attributes that are mass assignable.
     * @var array
    protected $fillable = [
        'name', 'email', 'password',

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

#5: Add Email Route

Go to the routes/web.php file and add the extra parameter inside Auth:: routes().

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

This enables the new Verification controller with the route actions.

Also, we want to protect the HomeController route, so let us do that via adding middleware.


public function __construct()

#6: Configure Email

I am using mailtrap for this example. So log in to the

Move to the demo inbox and copy the credentials and paste to your .env file.


MAIL_USERNAME=Enter Your Username
MAIL_PASSWORD=Enter Your Password

#7: Test the email verification functionality

Go to the browser and  type following url on your browser: http://localhost:8000/register

You will see the page like below screenshot.

laravel 5.7 email verification example

Now you can go the mailtrap, and you can see that verification mail has arrived.

laravel email verification tutorial

Also, you can see the database users table and analyze that there is still null in email_verified_at.

laravel 5.7 email verification tutorial

Now, you can click the link that is arrived at your email and your email will be verified and you can see here timestamp will be registered.

laravel email verification

Finally, Our Laravel 5.7 Email Verification Example Tutorial is over. Thanks for taking.

1 thought on “Laravel 5.7 Email Verification Example Tutorial”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.