Mail ::队列不起作用 [英] Mail::queue not working

查看:208
本文介绍了Mail ::队列不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在laravel 5.4中将电子邮件排队.在以前的laravel 5.3项目中,一切正常.

i'm unable to queue emails in laravel 5.4. in previous laravel 5.3 projects all worked fine.

发送仍然有效:

Mail::send('email.blank', ['title' => 'nice', 'content' => 'message'], function ($message)
        {
            $message->from('a@b.com', 'test');
            $message->to('a@b.com');
        });

队列不起作用:

Mail::queue('email.blank', ['title' => 'nice', 'content' => 'message'], function ($message)
        {
            $message->from('a@b.com', 'test');
            $message->to('a@b.com');
        });

出现以下错误:

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

我已经创建了队列表

php artisan queue:table
php artisan migrate

并将驱动程序更改为数据库

and changed the driver to database

UPDATE 看起来在laravel 5.4中,您只能使用可邮寄邮件对电子邮件进行排队

UPDATE it looks like in laravel 5.4 you are only able to queue emails using mailables

php artisan make:mail TestMail

在新创建的类中,更改build函数以返回现有视图,例如

within the newly created class change the build function to return an existing view e.g

public function build()
    {
        return $this->view('email.test');
    }

然后将邮件排队

 Mail::to('a@b.com')->send(new TestMail());

谢谢

推荐答案

队列电子邮件正在使用此脚本

the queue email is use this script

Mail::to('a@b.com')->queue(new TestMail());

代替

Mail::to('a@b.com')->send(new TestMail());// this just commonly sent email not queueing

这篇关于Mail ::队列不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆