我在laravel 5.3中使用此代码发送电子邮件。但它说未定义的变量$ email,而我已经定义了变量。 这是我的代码。
$user->save();
if (!empty($user->save())) {
$email = 'ppriyadarshi49@gmail.com';
$mail = Mail::send('email_page', ['verification_key' => $verification_code], function($message) {
$message->from('prince.priyadarshi@fluper.com', 'Verify');
$message->to($email)
->subject('Verify your email address');
});
return view('for_company');
}
错误是未定义变量:电子邮件
答案 0 :(得分:0)
您在关闭函数中缺少use()
:
$user->save();
if (!empty($user->save())) {
$email = 'ppriyadarshi49@gmail.com';
$mail = Mail::send('email_page', ['verification_key' => $verification_code], function($message) use($email) {
$message->from('prince.priyadarshi@fluper.com', 'Verify');
$message->to($email)
->subject('Verify your email address');
});
return view('for_company');
}