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

aweb's avatar
Level 4

How to add rate limit to Resend Verification Email on page email/verify for Laravel Jetstream

Laravel Jetstream, when enabled email verification, when one registered, for any account management pages, it'll redirect to /email/verify page to inform user to verify email address.

My issue is the button Resend Verification Email on the page can be clicked without any restrictions. Imagine one boring person registered, and clicked the button again and again, then the same email send out again and again.

Thanks a lot for anyone could help to fix this.

1 like
7 replies
rodrigo.pedra's avatar
Level 56

Create a rate limiter on your AppServiceProvider and add a middleware to the controller:

<?php

namespace App\Providers;

use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\ServiceProvider;
use Laravel\Fortify\Http\Controllers\EmailVerificationNotificationController;

class AppServiceProvider extends ServiceProvider
{
    public function register()
    {
        $this->app->afterResolving(EmailVerificationNotificationController::class, function ($controller) {
            // use the name you set for your rate limiter below
            $controller->middleware('throttle:verification');
        });
    }

    public function boot()
    {
        // choose the name you want for your rate limiter
        RateLimiter::for('verification', function (Request $request) {
            return Limit::perMinute(3)->by($request->ip());
        });
    }
}

Note I used a blank AppServiceProvider to illustrate what you need to do. If you already have any additional code in your AppServiceProvider keep it.

1 like
FHoulbreque's avatar

@rodrigo.pedra Just wondering about this how I may intercept the 429 response to pass it as a flash to the reloading page, so I can put the answer in a toast alert...

Or I'll just make another livewire component as I did for every other option until now.

davexpression's avatar

Laravel Breeze already has this.

In routes/auth.php you have

Route::get('verify-email/{id}/{hash}', VerifyEmailController::class)
                ->middleware(['signed', 'throttle:6,1'])
                ->name('verification.verify');

Here's what throttle:6,1 means:

6: It represents the maximum number of attempts allowed within the specified timeframe.

1: It represents the number of minutes for which the user is throttled after reaching the maximum attempts.

Please or to participate in this conversation.