How do I pass the $email variable to Mail? And why is it not transmitted so? but just need to write for example

 $message->to('gogo@gmail.com', 'gogo@gmail.com')->subject('Login and Password'); 

She somehow undefined variable

 $email = 'gogo@gmail.com'; Mail::send('mail.mail', $data, function($message) { $message->to($email, $email)->subject('Login and Password'); $message->from('tests@gro.com','tests@gro.com'); }); 

    1 answer 1

     $email = 'gogo@gmail.com'; Mail::send('mail.mail', $data, function($message) use ($email) { $message->to($email, $email)->subject('Login and Password'); $message->from('tests@gro.com','tests@gro.com'); }); 

    It is necessary to transfer a variable to Closure

    use ($email)