Create SendWelcomeEmailNotification
notification
php artisan make:notification SendWelcomeEmailNotification
Create SendWelcomeEmail
listener on user registration
php artisan make:listener SendWelcomeEmail --event=Illuminate\\Auth\\Events\\Registered
Open up App\Listeners\SenWelcomeEmail.php
, add the following lines:
$event->user->notify(
new SendWelcomeEmailNotification()
);
Then register App\Listeners\SenWelcomeEmail
to Illuminate\Auth\Events\Registered
in app\Providers\EventServiceProvider.php
.
protected $listen = [
'Illuminate\Auth\Events\Registered' => [
'App\Listeners\SendWelcomeEmail',
],
];
Please ensured to setup your database and emails connection, and migrate the existing migration scripts.
php artisan migrate
Then you're ready to register. You should receive email once registered.