It shows $data as not defined.
ErrorException in MailController.php line 22:
I tried my best with the help of laravel's tutorial point site. But I was unable to send the mail dynamically.
Below is my mailcontroller.php
MailController.php
public function contact(Request $request)
{   
    echo $email=$request->input('email');
    echo $name=$request->input('name');
    echo $message=$request->input('message');
    $data = array('name'=>$name,'email'=>$email,'message'=>$message);
    Mail::send(['text'=>'mail'], ['data'=>$data], function($message) 
    {
        $message->to('aa@gmail.com',$data->message)->subject
        ('Feedback');
        $message->from($data->email,$data->name);
    });
   echo "HTML Email Sent. Check your inbox.";
}
 
     
    