我想向刚刚输入电子邮件地址的用户发送电子邮件。
像这样,
$email = $request->email;
Mail::send('emails.info', $data, function ($message) {
$message->from('myemail@gmail.com', 'My Email');
$message->to($email)->subject('The subject');
});
Run Code Online (Sandbox Code Playgroud)
但这返回一个错误:
未定义变量:电子邮件
问题出在哪里?
您需要在封包使用用途中引用电子邮件
$email = $request->email;
Mail::send('emails.info', $data, function ($message) use ($email) {
$message->from('myemail@gmail.com', 'My Email');
$message->to($email)->subject('The subject');
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2652 次 |
| 最近记录: |