我要使用laravel发送邮件
所以我有
$mailD = DB::table('users')->select('name','email')->where('id', $request->input('Appraiserid'))->get();
$toemail = $mailD[0]->email;
当我回显$ toemail时,它将回显值。
当我发送邮件时
if ($update) {
$datamail = [
'title' => $getcycle[0]->Heading,
'Heading' => 'Form Reject',
'Name' => $mailD[0]->name,
'email' => $mailD[0]->email
];
Mail::send('voyager::users.send', ["data1" => $datamail], function ($message) {
$message->subject('Form reject');
$message->from('test@gmail.com');
$message->to($toemail);
});
}
出现了类似的错误
Users.php第631行中的ErrorException:未定义的变量:toemail
任何帮助将不胜感激。
答案 0 :(得分:1)
尝试使用此代码获取更多see
Mail::send('voyager::users.send', ["data1"=>$datamail], function ($message) use ($toemail) {
$message->subject('Form reject');
$message->from('test@gmail.com');
$message->to($toemail);
});