简体   繁体   English

我正在尝试在Laravel 5.2中发送电子邮件。 它给我的错误是“ Mailer.php第410行中的InvalidArgumentException:回调无效。”

[英]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.

相关问题 卷曲电子邮件错误mailer.php - curl email error mailer.php Laravel 5.2 FilesystemManager.php 第 121 行中的 InvalidArgumentException:不支持驱动程序 [] - Laravel 5.2 InvalidArgumentException in FilesystemManager.php line 121: Driver [] is not supported 如何通过Google Apps发送网站mailer.php电子邮件 - How to send sites mailer.php emails through Google Apps 尝试使用PHP邮件程序发送响应式电子邮件 - Trying to send a responsive email using PHP mailer 尝试在Laravel 5.2中向多个用户发送电子邮件 - Trying to send email to multiple users in Laravel 5.2 Laravel 从 5.1.46 更新到 5.2.* php artisan Segmentation fault - Laravel update from 5.1.46 to 5.2.* php artisan Segmentation fault 全新安装 Laravel 5.2。 siteurl/public/index.php 给了我一个 500.19 “web.config” 错误 - New installation of laravel 5.2. siteurl/public/index.php gives me a 500.19 “web.config” error PHPMailer给出错误消息:“ PHP解析错误:解析错误,第23行的mailer.php中出现意外的'{'” - PHPMailer Gives Error Message: “PHP Parse error: parse error, unexpected '{' in mailer.php on line 23” 为什么我可以使用Swift Mailer从本地主机发送电子邮件,而不能使用PHP的mail()函数发送电子邮件? - Why am i able to send email from localhost using Swift Mailer but not with PHP's mail() function? 尝试使用Swift Mailer发送电子邮件时出现PHP错误 - PHP error when trying to send email using Swift Mailer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM