简体   繁体   English

流明邮件的默认排队

[英]Default queueing of Lumen Mailables

From Laravel documentation: 从Laravel文档中:

Queueing By Default 默认排队

If you have mailable classes that you want to always be queued, you may implement the ShouldQueue contract on the class. 如果您有希望始终排队的可邮寄类,则可以在该类上实现ShouldQueue契约。 Now, even if you call the send method when mailing, the mailable will still be queued since it implements the contract 现在,即使您在邮寄时调用send方法,可邮寄邮件仍会排队,因为它实现了合同

Is there a way to default queue emails even when calling Mail:send as in Laravel but in Lumen? 是否有一种默认方法,即使在Laravel中但在Lumen中调用Mail:send时也可以将电子邮件默认排队?

I've tried implementing the ShouldQueue contract on my Mailables but they still get sent right away, my queues are working as I use them explictly in other cases. 我曾尝试在Mailables上实现ShouldQueue合同,但它们仍会立即发送,我的队列正在工作,因为在其他情况下会显式使用它们。

First, make sure you have QUEUE_DRIVER other than sync in .env file. 首先,请确保除了.env文件中的sync文件之外,您还拥有QUEUE_DRIVER Use database , beanstalkd , or redis driver. 使用databasebeanstalkdredis驱动程序。

Second, if you get queue is null error, you must bind the queue first. 其次,如果您获得queue is null错误,则必须首先绑定队列。

app('queue');
Mail::to($email)->send($mailable);

or if your mailable doesn't implement ShouldQueue 或者您的可邮寄邮件未实现ShouldQueue

app('queue');
Mail::to($email)->queue($mailable);

Source 资源

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM