Bogardo / Mailgun

Mailgun package for Laravel
MIT License
295 stars 116 forks source link

sending a batch mail, not recognizing the to array I have created #131

Closed joydipnath closed 6 years ago

joydipnath commented 6 years ago

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

Fab-Miami commented 5 years ago

Same issue! Did you figure out a solution (I know, was 18 months ago... but still ^^)

Fab-Miami commented 5 years ago

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'] ); }

joydipnath commented 5 years ago

Yes, I got the solution. Thanks a lot for your suggestion.