create a user and send a verification email

Has anyone managed to create a user and then send a verification email, for example via mailcatcher to test, I think I've already tried with the documentation and some tutorials and I didn't succeed, can anyone shed some light?
1 Reply
Igor
Igor6mo ago
Hi João, I did something similar using the Events and Listerners from laravel, when the user is created the Eloquent emit a UserCreated, so listen for that event and send the email with:
public function handle(UserCreated $event): void { $user = $event->user; $token = app('auth.password.broker')->createToken($user); $notification = new \Filament\Notifications\Auth\ResetPassword($token); $notification->url = \Filament\Facades\Filament::getResetPasswordUrl($token, $user); $user->notify($notification); Log::info('Sent reset password email', ['email' => $user->email]); }
the laravel recomends the use of mailpit for development, and to get the correct URL to return to app you need to set the APP_URL env