Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

laravel_beginner's avatar

Laravel 9 email verification

I am trying to do email verification with laravel documentation : https://laravel.com/docs/9.x/verification My web.php looks like this Route::get("/", [\App\Http\Controllers\WelcomeController::class, "home"]); Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home'); Route::post("/product/store", [\App\Http\Controllers\ProductController::class, "storeProduct"]);

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('/'); })->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');

Route::get('/profile', function () { })->middleware(['auth', 'verified']);

Route::middleware(["auth"])->group(function () { Route::resource("/admin", \App\Http\Controllers\AdminController::class); }); Auth::routes();

And after registration I will get email to verify my email thanks to implementing MustVerifyEmail. But I won't get the notification about it in the laravel application, which should do route named verification.notice and with middleware it should automatically done it, but anything happens. Any ideas where is the mistake?

0 likes
3 replies
OussamaMater's avatar

First of all, please wrap the code in ``` like so

 ```
code goes here
 ```

This helps us read your code better, otherwise I see no issues, when you protect the routes with the verified middleware it will redirect any unverified user to a route called verification.notice which you already have defined, that route will return a view called verify-email found in directory called auth under the views directory, it's up to you what show in that view, Laravel will only handle the redirecting part, but once redirected to that view, you display a message like please verify your email or whatever you want

Hopefully this made the idea clear for you.

laravel_beginner's avatar

@OussamaMater Thanks for your answer. I am new here so thank you for the advise, where to place code. I really appreciated it. I get what you are saying, but in auth under view is none default view called view-email. I tried to create one and put my code here, but nothing changed. But in the auth directory is view called verify, which has everything in it, even things like send email again and so on, so I suppose that this is the view which should be called with verification.notice

OussamaMater's avatar

@laravel_beginner No, it has nothing to do with that, the verification.notice is a name's route that Laravel used to redirect all unverified users there, in your return view method make sure to return a view that exists

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

You need to have a file called verify.blade.php in your resources/views/auth/ which has a message let's say Please verify your email, this should do it, give it a go and it will work fine :)

Please or to participate in this conversation.