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

sikic's avatar
Level 1

Spark - implementing email verification

Did anyone try to implement new email verification in Spark 7? In Spark documentation, it is described to add an implementation of MustVerifyEmail contract in the User model which has no effect.

Mentioned SparkServerProvider class doesn't even exist in the whole project, as well as ensureEmailIsVerified method.

Can anyone give tips on how to make email verification properly work in Spark?

0 likes
8 replies
vmitchell85's avatar
Level 10

I suspect it should be SparkServiceProvider instead of SparkServerProvider. The only other thing to ensure is that you are running Spark 7.1 and not 7.0.

Other than that it should work just as the documentation states.

1 like
danielmeade's avatar

@sikic I'm having the same issue as you, did you ever get this one solved?

I figured the docs meant SparkServiceProvider rather than SparkServerProvider, but even so, after following the docs I'm still not able to get this working.

Running 7.1

##EDIT - I Have it working!

Here are some steps you need to take in addition to the docs:

Note: If there is no register method in your SparkServiceProvider, create one.

  • Go to your HTTP\Kernel.php and within routeMiddleware add 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class if it doesn't already exist.
  • Run php artisan migrate
  • If no migration happens, you'll need to create one to add an email_verified_at column within the users table, its type should be timestamp. Probably best to add it right after email

Finally, if you're working locally and you're still not getting the verification email sent to you, it's likely because you don't have an email server set up - create a temporary (free) one with https://mailtrap.io and you'll be good to go.

4 likes
JuanDBB's avatar

@danielmeade Hi Daniel, I added the middleware route, the "use Illuminate\Contracts\Auth\MustVerifyEmail;" at User.php, added the email_verified_at column and added this to SparkServiceProvider: public function register() { Spark::ensureEmailIsVerified(); } but I'm getting no verification emails to mailtrap (it's working for other emails notifications) Did I miss something? Thank you!

danielmeade's avatar

@JUANDBB - Have you run php artisan migrate?

Also, it might be good to check that the email_verified_at field type in your database is set to TIMESTAMP.

mailnike's avatar

Hi, I got this working. However, whenever user registers, he gets automatically logged in even if email is not verified. Do I need apply this middleware "->middleware('verified');" to all the routes manually? I thought it will work on the registration form itself, forcing users to verify their email. However, this option is also not that bad, as it let users complete the login flow and verify email once they see the dashboard, kind of soft touch.

Cronix's avatar

Do I need apply this middleware "->middleware('verified');" to all the routes manually?

Yes, but it's a lot easier to just create a single route group that uses that middleware, and put your routes in that one group.

Route::middleware(['verified'])->group(function () {
    // all routes requiring verified middleware go here
});
1 like

Please or to participate in this conversation.