Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sent mail to multiple address using Laravel 4 queue

I'm using Laravel 4 , tying to send mail to multiple user using Queueing Mail , my code looks like -

$mailuserlist=DB::table('table')
            ->join('some_table')
            ->select('some_thing')
            ->where('somecondition'))->get();

Mail::queue('mail_template', $data, function($message) use ($mailuserlist)
{
      $message->from('[email protected]', 'Mail Notification');
      foreach ($mailuserlist as $value) {
            $message->to($value['email'],$value['firstname'].' '.$value['lastname']);
    }
    $message->subject('Testing mail');
});

..it's not at all working . How can i send ail to multiple address ??

like image 670
Chinmoy Avatar asked May 08 '26 16:05

Chinmoy


1 Answers

It should be possible in two ways as we can see in the source code framework/src/Illuminate/Mail/Message.php:

  1. Chaining
  2. Using array

Chaining:

->to($address1, $name1)->to($address2, $name2)->to($address3, $name3)...

Using array of addresses:

->to(array($address1,$address2,$address3,...), array($name1,$name2,$name3,...))
like image 143
itsazzad Avatar answered May 11 '26 04:05

itsazzad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!