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

Emmanuel71's avatar

Laravel11 + Jetstream + Filament + Socialite: Email verification sent twice

I suddenly noticed that the email verification mail in my project is sent twice after users have registered. Actually the command "event(new Registered($user));" generates two emails. I'm not sure if it started after upgrading to laravel 11 or after adding socialite or if it is some other reason.

Any ideas how to debug this or what the reason could be?

Thx, Emmanuel

0 likes
23 replies
LaryAI's avatar
Level 58

To address the issue of email verification being sent twice in your Laravel project, you can follow these steps to debug and potentially resolve the problem:

  1. Check for Duplicate Event Listeners: Ensure that the Registered event is not being listened to more than once. You can do this by checking your EventServiceProvider and any other places where you might be registering event listeners.

    // app/Providers/EventServiceProvider.php
    
    protected $listen = [
        Registered::class => [
            SendEmailVerificationNotification::class,
        ],
    ];
    
  2. Check for Multiple Event Dispatches: Make sure that the event(new Registered($user)); is not being called multiple times in your registration process. This can happen if you have custom registration logic that might be dispatching the event more than once.

  3. Check for Middleware or Traits: If you are using any middleware or traits that might be dispatching the Registered event, ensure that they are not causing the event to be fired multiple times.

  4. Debugging with Logs: Add logging to your event listener to see if it is being triggered more than once.

    // app/Listeners/SendEmailVerificationNotification.php
    
    use Illuminate\Support\Facades\Log;
    
    public function handle(Registered $event)
    {
        Log::info('SendEmailVerificationNotification triggered for user: ' . $event->user->id);
        $event->user->sendEmailVerificationNotification();
    }
    

    Check your log files to see if the listener is being triggered multiple times.

  5. Check for Socialite Integration: If you have integrated Socialite, ensure that the registration process for social logins is not causing the Registered event to be dispatched again. Sometimes, social login providers might trigger the registration event separately.

  6. Check for Custom Code: Review any custom code you have added for user registration or email verification to ensure it is not causing the duplication.

By following these steps, you should be able to identify the root cause of the issue and resolve the problem of email verification being sent twice. If you still face issues, consider sharing more details about your registration process and any custom code you have added, so that further assistance can be provided.

Emmanuel71's avatar

Already tried these options with ChatGPT. It doesn't resolve the mails being sent twice. Also performed a 'composer update' in the hope it was an already fixed bug, but no success.

Emmanuel71's avatar

I reverted to the commits just before and just after the upgrade to laravel 11. The problem starts after upgrading from laravel 10 to laravel 11, which also required an upgrade to Jetstream.

Emmanuel71's avatar

Checked using xdebug and after a long and (for myself) mysterious journey under the hood of laravel, I could indeed see that the email notification is sent out twice. But it gave me no clue why.

Ended up overriding SendEmailVerificationNotification and listening for the registered event in EventServiceProvider. Also needed to remove MustVerifyEmail from the user model. It seems to be solved now as the mail now only is sent once.

2 likes
bvfi-dev's avatar

The MustVerifyEmail on the User model comes from Jetstream. What happens when you disable the EmailVerification feature for Jetstream? Well, actually, I guess that kind of solves your problem. I think what happened here is you used 2 Email Verification services that come packaged with some of these frameworks, so you just needed to disable one.

jeremyc's avatar

I also am having this issue. GPT actually suggested the following:

app('events')->forget(Registered::class);

Which actually fixed the issue. I'm guessing it's being registered twice in the core somewhere, but I haven't been able to find where.

2 likes
Aldrindelacruz's avatar

@jeremyc My findings so far: yes it is being registered twice.

  1. from Illuminate\Foundation\Support\Providers\EventServiceProvider::class -> configureEmailVerification() and
  2. Laravel automatically registers the Illuminate\Auth\Listeners\SendEmailVerificationNotification listener for the Illuminate\Auth\Events\Registered event.
1 like
Emmanuel71's avatar

Thank you both for your feedback!

Are you guys also using Socialite, Filament & Jetstream? Just to rule out if it's an issue in the Laravel core itself or in combination with the packages mentioned.

christian98's avatar

My findings so far: In my application my custom App\Providers\EventServiceProvider and the frameworks Illuminate\Foundation\Support\Providers\EventServiceProvider both get called during a request lifecycle. (I did so by adding ray()->trace() to both classes)

I did change the project structure to match the new skeleton during the upgrade (I know this is not recommended :D ).

Emmanuel71's avatar

Thanks for the feedback everyone! I did not move to the new skeleton, but still the problem occurs. Might be a bug in Fortify/Jetstream after upgrading to L11? Any advice for reporting this issue somewhere?

Aldrindelacruz's avatar

I encountered the same issue after upgrading from 10 to 11, what i found causing the issue is that, laravel 11 dont need EventServiceProvider and auto discovering listener if event is type-hinted and start with handle or __invoke method., now after we upgrade Illuminate\Auth\Listeners\SendEmailVerificationNotification is registered twice (you can check with artisan event:list look for Illuminate\Auth\Events\Registered and you will see what listened to it)

It is registered twice because, 1) because the auto discovery and 2) it is added via configureEmailVerification() method from Illuminate\Foundation\Support\Providers\EventServiceProvider

My resolution is adding configureEmailVerification() method that returns nothing, and check event:list and SendEmailVerificationNotification is no longer registered twice, and it resolve the issue of sending 2 verify email.

Note: solution is not recommended, it is just a quick fix and still need to change event and listener implementation. need to follow new docs.

2 likes
Franche020's avatar

Hello,

I had the same issue after upgrade from LV10 to LV11,

I found that one of the register events came from config/app.php so I just comment the EventServiceProvider and delete the file from app/Providers

With this two steps I been able to get rid of double mail

'providers' => ServiceProvider::defaultProviders()->merge([
    /*
     * Package Service Providers...
     */

    /*
     * Application Service Providers...
     */
    App\Providers\AppServiceProvider::class,
    App\Providers\AuthServiceProvider::class,
    // App\Providers\BroadcastServiceProvider::class,
    //App\Providers\EventServiceProvider::class,
    App\Providers\RouteServiceProvider::class,
    App\Providers\TelescopeServiceProvider::class,
])->toArray(),

Hope this work for the rest of us, Thank you very much for your help that put me on the right way

ufodisko's avatar

I'm having the same issue, verification email being sent twice. Using Jetstream (Inertia) and Filament.

Anyone has a solution, please?

Edit: @jeremyc solution worked. I ended up creating EventServiceProvider and clearing any existing listeners for the Registered event and then registering only the SendEmailVerificationNotification listener, effectively preventing multiple email verifications.

namespace App\Providers;

use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;

class EventServiceProvider extends ServiceProvider
{
    protected $listen = [
        Registered::class => [
            SendEmailVerificationNotification::class,
        ],
    ];

    public function boot()
    {
        app('events')->forget(Registered::class);

        parent::boot();
    }
}
1 like
kerkness's avatar

@ufodisko This approach also worked for me... I have socialite and I am also using fortify

angelsky's avatar

If someone has the time, this bug should be reported to the laravel dev team. Link to this thread should be enough.

ignaciodev's avatar

Same issue here. I found that removing all service providers except for AppServiceProvider and doing all the work in there fixed the issue. As soon as you create a class that extends ServiceProvider the issue comes back.

ian_h's avatar

I can't remember exactly what version it was, but Laravel now includes auto-discovery for events, which means if you're defining them in a service provider too, they'll fire twice and likely the reason for this issue.

You can disable the auto-discovery process putting the following into your EventServiceProvider (or whatever provider you use to define your events) boot method:

static::disableEventDiscovery();

This will then rely on the previous design of manually registering the events.

Please or to participate in this conversation.