After User Registration Send A Welcome Email Notification In Laravel 8 - FreeCodeBlog
Last updated: Dec 11, 2021
Read this tutorial carefully to send a welcome email notification in laravel 8 after user registration. Suppose you have a laravel 8 project and now you want to send an email notification to registered user when a user register her account via email.

Open .env file and edit mail section for email sending. In this tutorial, I will use mailtrap for email notification sending.
MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=your-mailtrap-username
MAIL_PASSWORD=your-mailtrap-password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=example@gmail.com
MAIL_FROM_NAME="${APP_NAME}"
Copy below url and paste on any browser and hit enter.
127.0.0.1:8000/register
Connect wifi to your device and register a user. You will get an email verification notification email on mailtrap dashboard after registration.
Now I want to send a welcome email notification when a user registered. Remember I don't develop user email verification. I just send an email when user registered.
Open EventServiceProvider and add verified event and Listener.
<?php
namespace App\Providers;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use App\Listeners\WelcomeEmailListener;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
Registered::class => [
WelcomeEmailListener::class,
SendEmailVerificationNotification::class,
],
];
/**
* Register any events for your application.
*
* @return void
*/
public function boot()
{
//
}
}
You need to run event command to generate event and Listener.
php artisan event:generate
Now make a notification to send after user registered.
php artisan make:notification WelcomeEmailNotification
Open WelcomeEmailListener Listener and add WelcomeEmailNotification.
<?php
namespace App\Listeners;
use Illuminate\Auth\Events\Registered;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use App\Notifications\WelcomeEmailNotification;
class WelcomeEmailListener
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param Registered $event
* @return void
*/
public function handle(Registered $event)
{
$event->user->notify(new WelcomeEmailNotification());
}
}
User will get an email notification after registered.
Okay so this is for today. See you again next tutorials. Thanks

My name is Masum Biswas. I'm a full stack developer. I live in Bangladesh and I love to write tutorials and tools that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, MySQL, VueJS, Tailwind CSS and Bootstrap from the early stage.
In this tutorial we can learn how we can send a email when a user verified her email. We need to send email because email verified success email im... Read More
Are you using laravel 8 jetstream vue 3 to download a file? Yes. Well, want to make a file download system in laravel 8 with jetstream vue 3? Yes.... Read More
Laravel 8, Vue 3, Ckeditor 5. Do you really want to use ckeditor 5 on laravel 8 with vue 3? Yes. Do you know about ckeditor 5? A little bit. Ckedit... Read More
Want to use vue 3 in laravel ui? Laravel ui is a first party user authentication package and you can easily use it with laravel 8 and vue 3. So let... Read More
Today I will explain you, how we can easily deploy a laravel 8 project on namecheap shared hosting cpanel. If you have a namecheap shared hosting s... Read More