in this blog you are going to see that whenever you want to send email to multiple user then your view page takes a lot of time. so how can you decrease the load time and send email in background.
first of all you should create a folder Jobs under app and add two files eg. job.php and MailJob.php and now see both files code and add it to your files as well.
create a file to this location (app/Jobs/job.php) and put below codes in it.
Now create another file name MailJob.php and put below code:
and add below code to your SampleMail.php (app/Mail) location
now change some code in your store function of your Controller.php
now you should check you have a jobs table in your database. for this you should create a migration by putting below command
php artisan queue:table
For more reference see this article Click Here
Now you should run a command in terminal for processing queues:
php artisan queue:work
after this whenever you click on submit button in your form your form will submitted within 2 to 3 second and your email will process in the background and your request of email should be partially stored in jobs table.
for more details you can refer below articles:
Click Here: reference of queue
- Top 10 DevOps Blogs and Websites To Follow in 2023 - December 13, 2022
- How To Set Up Apache Virtual Hosts on Ubuntu 20.04.2 LTS - October 28, 2021
- How to Fix ” Vue packages version mismatch:” error in Laravel 5.5 - April 15, 2021