Please run your laravel project using the php artisan serve command, then try to register with an active email. With this code, after the user registers, it will send an email from the WelcomeEmailNotification class to the user's email.
In the function create, change or add the code as above. Next, open the file in app/Http/Controllers/Auth/RegisterController.php. $user->notify(new WelcomeEmailNotification()) Step 6: Setup RegisterController protected function create(array $data) After running the command, we now have a WelcomeEmailNotification.php file located in the app/Notifications directory. Then, generate notification class using artisan command as above. Step 5: Generate Notification php artisan make:notification WelcomeEmailNotification *Before installing the laravel ui package, make sure you have entered the project directory by running the cd laravel-welcome-email-notification command in the terminal.
Please install the laravel ui package in our laravel project by running the commands as above sequentially. For that, here I give an example using the laravel ui package to create the authentication feature. We need authentication features (register, login and logout) to implement sending a welcome email notification to the user after register.
Read: How To Send Email With Gmail In Laravel Step 4: Install Laravel UI composer require laravel/ui Before using gmail as an email sender in laravel, make sure "Less secure app access" in your google settings is in ON condition. env file also needs to be adjusted like the example above. Because in this experiment, we will send email with gmail in laravel 8, so the. Step 3: Setup Sender in the third step, which is to setup the email sender. Then don't forget to also adjust the DB_DATABASE in the. Here I give an example, I created a new database with the name Laravel_welcome_email_notification. If you are using xampp as local development, please create a new database at localhost/phpmyadmin. Next, create a new database to store sample data that we will use in this experiment. Step 2: Setup Database DB_CONNECTION=mysqlĭB_DATABASE=laravel_welcome_email_notification From the two examples of laravel installation commands above, they will both generate a laravel project with the name laravel-welcome-email-notification. Please choose one method you want to use for laravel installation. To install laravel you can use laravel installer or use composer like the example above. In this first step, we need to install the latest version of laravel (currently version 8) which we will try to implement sending a welcome email notification after the user registers in laravel 8. Laravel new laravel-welcome-email-notificationĬomposer create-project laravel/laravel laravel-welcome-email-notification ? ?? Step 1: Install Laravel //via Laravel InstallerĬomposer global require laravel/installer Alright, let's get straight to the coding to try to create a welcome email notification in laravel 8.