Reputation: 520
I am trying to send email using Laravel, but I am getting the error message
"Undefined index: email"
Here is my code
public function contact_us(Request $request){
$cu_full_name = $request->cu_full_name;
$cu_email = $request->cu_email;
$cu_message = $request->cu_message;
date_default_timezone_set("Asia/Kolkata");
$cu_received_dt = date("Y-m-d,H:i:s ");
$data= array([
'name'=>$cu_full_name,
'email'=> $cu_email,
'message'=>$cu_message
]);
Mail::send('emails.home',$data,function ($message) use($data){
$message->from('[email protected]');
$message->to($data['email'])->subject('New Message Received.'); **<-error message for this line**
});
//Other codes
Upvotes: 0
Views: 333
Reputation: 1641
Why are you wrapping array inside array ?
try to define data
like that :
$data= [
'name'=>$cu_full_name,
'email'=> $cu_email,
'message'=>$cu_message
];
Or,
$data= array(
'name'=> $cu_full_name,
'email'=> $cu_email,
'message'=> $cu_message
);
Upvotes: 1