Closed joydipnath closed 6 years ago
Same issue! Did you figure out a solution (I know, was 18 months ago... but still ^^)
OK, I figured it out: foreach ($mailing->recipient as $key => $recipient) { $recipients[$recipient->email]= array( 'first_name' => $recipient['first_name'], 'last_name' => $recipient['last_name'] ); }
Yes, I got the solution. Thanks a lot for your suggestion.
foreach ($result as $key => $value) { array_push($recipients, array( $value['email'] => array( 'c_name' => $value['fname']." ".$value['lname'],'user_id' => $value['user_id'] ))); }
Then I am passing $recipients to send() function as suggested on document.
$data = array ('email' => $request->email_id, 'subject' => $request->email_sub ); Mailgun::send('recruiter.test_mail', $data, function ($message) use($request, $recipients, $recipientVariable){ $message->from($request->email); $message->subject($request->subject); $message->to($recipients); });
But if I hard code $recipients variable as shown in document it works.
$recipients = array( "foo@bar.com" => array( 'first' => 'Foo', 'last' => 'Bar' ), "johndoe@example.com" => array( 'first' => 'John', 'last' => 'Doe' ) );
Any help would be appreciated. Thanks