Laravel 电子邮件功能 - REST API
Laravel Email Function - REST API
Quick Fire 问题,我正在使用 laravel 5.1 的邮件功能,但它仍然给我 variable not defined 错误,我已经调试并检查了我正在打印的变量是否有效。
$email_id = $users[0]['email_id'];
//i have checked $email_id by printing and it is working.
Mail::send('emails.forgetpassword', ['title' => $title, 'name' => $name, 'content' => $content, 'link' => $link], function ($message)
{
$message->from('xyz@gmail.com', 'xyz Team');
$message->to($email_id);
$message->subject('xyz App - Forget Password');
});
我已经检查了文档我不知道它缺少什么。
它在这一行抛出错误
$message->to($email_id);
我不知道为什么 $email_id 已经定义并且可以工作了。
$email_id = $users[0]['email_id'];
//i have checked $email_id by printing and it is working.
Mail::send('emails.forgetpassword',
[
'title' => $title,
'name' => $name,
'content' => $content,
'link' => $link
],
function ($message) use($email_id) {
$message->from('xyz@gmail.com', 'xyz Team');
$message->to($email_id);
$message->subject('xyz App - Forget Password');
}
);
您需要将email_id发送给匿名函数。它在匿名函数的范围内未定义
Quick Fire 问题,我正在使用 laravel 5.1 的邮件功能,但它仍然给我 variable not defined 错误,我已经调试并检查了我正在打印的变量是否有效。
$email_id = $users[0]['email_id'];
//i have checked $email_id by printing and it is working.
Mail::send('emails.forgetpassword', ['title' => $title, 'name' => $name, 'content' => $content, 'link' => $link], function ($message)
{
$message->from('xyz@gmail.com', 'xyz Team');
$message->to($email_id);
$message->subject('xyz App - Forget Password');
});
我已经检查了文档我不知道它缺少什么。 它在这一行抛出错误
$message->to($email_id);
我不知道为什么 $email_id 已经定义并且可以工作了。
$email_id = $users[0]['email_id'];
//i have checked $email_id by printing and it is working.
Mail::send('emails.forgetpassword',
[
'title' => $title,
'name' => $name,
'content' => $content,
'link' => $link
],
function ($message) use($email_id) {
$message->from('xyz@gmail.com', 'xyz Team');
$message->to($email_id);
$message->subject('xyz App - Forget Password');
}
);
您需要将email_id发送给匿名函数。它在匿名函数的范围内未定义