[英]Mailgun sending email laravel
i use mailgun and the setting is done and i've test it and work, but i dont understand why i can't send email without array, here i tried using array but idk why it's error said Undefined variable: data我使用mailgun并且设置已经完成并且我已经对其进行了测试并且可以工作,但是我不明白为什么我不能在没有数组的情况下发送电子邮件,在这里我尝试使用数组但是我知道为什么它是错误的未定义变量:数据
public function kirim(Request $request){
$data = array(
'email_address'=>$request->email_address,
'cc'=>$request->cc,
'subject'=>$request->subject,
'keterangantambahan'=>$request->keterangantambahan
);
Mail::send('laporan.kirim', $data, function($message) {
$message->from('christian7andrew@gmail.com', 'PuraBox');
$message->to($data['email_address']);
});
return redirect('/');
}
any idea how to use array corectly ??知道如何正确使用数组吗?
Use a use
.使用一个
use
。
Looks like you are using a php version which supports closures看起来您使用的是支持闭包的 php 版本
Mail::send('laporan.kirim', $data, function($message) use ($data) {
$message->from('christian7andrew@gmail.com', 'PuraBox');
$message->to($data['email_address']);
});
The second parameter of the send()
method is to set mail options . send()
方法的第二个参数是设置邮件选项。 Does not place the variable inside the function body.不将变量放在函数体内。
The use
puts variables into the body of the function use
将变量放入函数体中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.