laravel 邮件::队列不工作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42227186/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Mail::queue not working
提问by markus
i'm unable to queue emails in laravel 5.4. in previous laravel 5.3 projects all worked fine.
我无法在 laravel 5.4 中排队电子邮件。在之前的 laravel 5.3 项目中,一切正常。
Send is still working:
发送仍然有效:
Mail::send('email.blank', ['title' => 'nice', 'content' => 'message'], function ($message)
{
$message->from('[email protected]', 'test');
$message->to('[email protected]');
});
Queue does not work:
队列不起作用:
Mail::queue('email.blank', ['title' => 'nice', 'content' => 'message'], function ($message)
{
$message->from('[email protected]', 'test');
$message->to('[email protected]');
});
With the following error:
出现以下错误:
InvalidArgumentException in Mailer.php line 314:
Only mailables may be queued.
in Mailer.php line 314
at Mailer->queue('email.blank', array('title' => 'nice', 'content' => 'message'), object(Closure)) in Facade.php line 221
at Facade::__callStatic('queue', array('email.blank', array('title' => 'nice', 'content' => 'message'), object(Closure))) in EmailController.php line 16
at EmailController->mailtest()
at call_user_func_array(array(object(EmailController), 'mailtest'), array()) in Controller.php line 55
at Controller->callAction('mailtest', array()) in ControllerDispatcher.php line 44
at ControllerDispatcher->dispatch(object(Route), object(EmailController), 'mailtest') in Route.php line 203
at Route->runController() in Route.php line 160
at Route->run() in Router.php line 559
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 30
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SubstituteBindings.php line 41
at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
I've created the queue table by
我已经创建了队列表
php artisan queue:table
php artisan migrate
and changed the driver to database
并将驱动程序更改为数据库
UPDATEit looks like in laravel 5.4 you are only able to queue emails using mailables
更新它看起来像在 laravel 5.4 你只能使用 mailables 排队电子邮件
php artisan make:mail TestMail
within the newly created class change the build function to return an existing view e.g
在新创建的类中更改构建函数以返回现有视图,例如
public function build()
{
return $this->view('email.test');
}
then queue the mail
然后排队邮件
Mail::to('[email protected]')->send(new TestMail());
thanks
谢谢
回答by user2963512
the queue email is use this script
队列电子邮件使用此脚本
Mail::to('[email protected]')->queue(new TestMail());
instead of
代替
Mail::to('[email protected]')->send(new TestMail());// this just commonly sent email not queueing