[英]I am trying to send email in Laravel 5.2. It giving me erros as “InvalidArgumentException in Mailer.php line 410: Callback is not valid.”
I have provided host ,username ,password,port no. 我提供了主机,用户名,密码,端口号。 in .env and config/mail.php.
在.env和config / mail.php中。 I am sending email from localhost.
我正在从本地主机发送电子邮件。
public function sendEmail(){
$data = array('name'=>"Swati Jadhav");
$arrCategory=Category::getCategory();
Mail::send('frontend.welcome',['arrCategory'=>$arrCategory] ,$data, function($message) {
$message->from('sender@gmail.com', 'text');
$message->to('receiver@gmail.com', 'text')->subject('Welcome!');
});
}
Mail::send
needs the callback as the 3rd parameter (not 4th). Mail::send
需要将回调作为第三个参数(而不是第4个)。 If you need to combine two parameter arrays you can do: 如果需要组合两个参数数组,则可以执行以下操作:
Mail::send('frontend.welcome',array_merge(['arrCategory'=>$arrCategory] ,$data), function($message) {
$message->from('sender@gmail.com', 'text');
$message->to('receiver@gmail.com', 'text')->subject('Welcome!');
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.