nam_co
270
8
Laravel

Mailable problem in loop

Posted 2 years ago by nam_co

Hello, hope somebody can help me, Im trying to send multiple emails from the controller

$message = (new SendMessage($account,$invoice,$client));

            foreach(request()->emails as $row){
                if($row){
                        Mail::to($row)->send($message);
                }
            }

doing dd(request()->emails); before shows me:

array:2 [▼
  0 => "[email protected] thefirstemail.com"
  1 => "[email protected] sendemail.com"
]

but this sends 2 emails:

  1. [email protected]
  2. [email protected] thefirstemail.com,[email protected] ( see how the second email includes both address, this also happens when its tree emails etc..

Appreciate any ideas

Please sign in or create an account to participate in this conversation.