I implemented auth system by
php artisan make:auth
and already setup user email verify by MustVerify from laravel feature
I want to send another email (Greeting mail) after user click verify link. How can I do that?
Solution :
When a user is registered a
Illuminate/Auth/Events/Verified
event is broadcast.
You can use this artisan command to generate a listener
php artisan make:listener SendWelcomeMail
In the listener you can add logic to the
handle($event)
function.
php artisan make:mail Greeting
or markdown mail : php artisan make:mail OrderShipped --markdown=emails.greeting
or markdown mail : php artisan make:mail OrderShipped --markdown=emails.greeting
public function handle(Verified $event)
{
Mail::to($event->user->email)->send(new Greeting());
}
Then you register the listener with the event in the
EventServiceProvider
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,
],
Verified::class => [
SendWelcomeMail::class
],
];
Links : https://stackoverflow.com/questions/55204228/laravel-5-8-how-to-send-email-after-user-click-verify-link