0
我想用變量主題發送電子郵件,這是代碼Sendmail的主題5.1
public function sendmail(Request $request)
{
$data = [
'subject' => $request->input('subject'),
'name' => $request->input('name'),
'phone' => $request->input('phone'),
'email' => $request->input('email')
];
Mail::send('mail.sendmail' , $data, function($msg){
$msg->from('mygmail.com', 'Avil');
$msg->to('[email protected]', 'Avil')->subject('Welcome to Laravel 5.1');
});
return redirect()->route('contact.index');
}
我想主題不是「歡迎Laravel 5.1」,主題是
public function sendmail(Request $request)
{
$data = [
'subject' => $request->input('subject'),
'name' => $request->input('name'),
'phone' => $request->input('phone'),
'email' => $request->input('email')
];
Mail::send('mail.sendmail' , $data, function($msg){
$msg->from('[email protected]', 'Hung Nguyen');
$msg->to('[email protected]', 'Hung Manh')->subject($data['subject']);
});
return redirect()->route('contact.index');
}
當我運行顯示錯誤:
未定義變量:數據
請幫幫我。非常感謝你