dimanche 12 mars 2017

Accessing email from MySQL db to be use for sending email

I have a problem with my message notification using email.Why is that it generates an error inside the foreach. The error is this part "$all_ngo" Undefined variable: all_ngo.

$pend = AddRequest::where('ship_id','=',$ship_id)->get();   
$all_ngo = [];
foreach ($pend as $id) {
    array_push($all_ngo, $id->ngo_id);
}

$orga_email  =  Auth::User()->orgainfo->orga_email;
$staffName  =   Auth::User()->orgainfo->inchargelname.' '. Auth::User()->orgainfo->inchargefname;  
$name = $scholars->scholar_fname.' '.$scholars->scholar_mname.' '.$scholars->scholar_lname;
$input =  array(
    'name' => $staffName,
    'email' => $orga_email,  
    'msgs' => 'asd' .' '. $name.'. '.'Hoping for your favorable response. Thank you!'
);
Mail::send('emails.mailMessage', $input,  function($message){
    $message->from('Somename@gmail.com');
    foreach ($all_ngo as $id3) {<-------Undefined variable: all_ngo
        $user = User::find($id3);
        $ngo_email2 = $user->ngo_email;
        $message->to($ngo_email2)->subject('Request For Sponsorship');
    }   
});



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire