[英]Laravel problems when sending email
When I'm trying to send an email using the swiftmailer in laravel I get the folowing error: "Missing argument 2 for UsersController::{closure}()". 当我尝试在laravel中使用swiftmailer发送电子邮件时,出现以下错误:“ UsersController :: {closure}()缺少参数2”。
My code is below: 我的代码如下:
Mail::send('emails.default', array('key' => Config::get('settings.WELCOMEMAIL')), function($message, $mail, $subject = 'Welcome!')
{
$message->to($mail)->subject($subject);
});
It's really weird though. 不过,这真的很奇怪。 The $mail variable contains a valid email address and I'm not using the UsersController at all in this script.
$ mail变量包含一个有效的电子邮件地址,在此脚本中我根本没有使用UsersController。
Thanks in advance 提前致谢
You must pass only the $message
to the closure. 您只能将
$message
给闭包。 Any additional variable must be passed down with the use
keyword: 任何其他变量必须
use
关键字传递:
Mail::send('emails.default', array('key' => Config::get('settings.WELCOMEMAIL')), function($message) use($mail, $subject)
{
$subject = empty($subject) ? 'Welcome!' : $subject;
$message->to($mail)->subject($subject);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.