public function postForgotPassword(Request $request)
{
if (\Auth::check() ) {
return redirect('/');
}
$user = \User::where("email", $request->input('email'))->get()->first();
$signature = (array(
"owner_name" => "Test",
"owner_rank" => "Super Admin"
));
$data = array(
"first_name" => $user->first_name,
"last_name" => $user->last_name,
"email" => $user->email,
"link" => ******,
"signature" => $signature
);
\Mail::send('email.password', $data, function($message) use ($user) {
$message->from("admin@test.com", "Test");
$message->to($user->email, $user->first_name." ".$user->last_name)->subject("Reset your password.");
});
return response()->json(["success" => true, "message" => "Check your email!"]);
}
我的电子邮件模板如下所示:
<div id="email">
<div style="width: 600px;">
<div style="width: 300px; float: left;">
<h3>{{ $last_name }} {{ $name }},</h3>
</div>
</div>
</div>
当我尝试发送电子邮件时,我收到此错误:
未定义的变量:名称
任何想法为什么?谢谢大家的时间!
答案 0 :(得分:1)
您应该从name
方法发送Mail::send()
参数,如下所示:
您似乎没有通过name
$data
的变量
$data = array(
"first_name" => $user->first_name,
"last_name" => $user->last_name,
"email" => $user->email,
"link" => ******,
"signature" => $signature,
'name' => 'enter_name_here' // <------- Specify your name here
);
希望这有帮助!