How to Implement Email Verification Using Laravel Jetstream (Fortify)
Thank you for your continued support.
This article contains advertisements that help fund our operations.
This post summarizes how to implement email verification using Laravel Jetstream (Fortify).
Prerequisites
Laravel 11
Jetstream is already installed
Official Laravel Jetstream (English)
Conclusion
config/fortify.php
Around line 149, there is a line of code commented out, so you need to uncomment it:
Features::emailVerification(),
App/Models/User.php
Around line 5, there is a line of code that is also commented out, so uncomment it as well:
use Illuminate\Contracts\Auth\MustVerifyEmail;
Then, at around line 14, implement the MustVerifyEmail interface:
class User extends Authenticatable implements MustVerifyEmail
That's it.
When you register a user on the registration page at localhost/register
, an email like the following will be sent:
When Emails Are Not Sent
If you do not configure the email sending settings, emails will not be sent.
In a production environment, it's common for small-scale development to contract a mail server to send emails.
For example, there are email services like AWS SES
and SendGrid
.
Since this is a development environment, it's easy to test using Mailtrap. Please read the following article for details:
→ How to Send Emails Using Mailtrap in Laravel
Possible Errors
Route [verification.verify] not defined.
This indicates that the settings in config/fortify.php
are not being reflected.
Please try running the following command to apply the settings:
php artisan config:clear
Conclusion
I summarized email verification for Fortify for those who have installed Jetstream.
I have tried to write it in a way that is as easy to understand as possible for beginners.
I hope you find it helpful.