0
votes

I've an application that sends a mail to list of emails after submit the form. For this I'm using queue jobs to send mail to that list in the background. I'm using SMTP for this with mailtrap. I'm new to this queue jobs functionality.

this is my controller code to dispatch queue:

public function sendMail(Request $request)
    {

    $lists = List::where('list_id',$request->list_id)->pluck('email')->toArray();
            $jobs = (new SendEmailToList($lists));
            $this->dispatch($jobs);
            return 'success';
    } 

And this is my job functionality in queue :

public function handle()
    {
        $lists = $this->lists;

            Mail::send('email.test', array('email' => 'Sample'), function ($message) use ($lists) {
                $message->to($lists);
            });

    }

I've a program file in the supervisor of my Linux system to queue:listen.

I've done all things but still it's not sending mail to all the list of emails. I've referred many of documentations but still same issue, all the documents given that to implement a QueueManager.

1

1 Answers

0
votes

You should probably call Mail::queue or Mail::later instead of Mail::send.

Please refer to Mail documentation in case you've been missing something else.