简体   繁体   English

Laravel如何安排邮件以便以后发送?

[英]How does Laravel schedule mails for later sending?

The Laravel Documentation describes the ability to schedule a mail for later delivery , with the following example: Laravel文档描述了使用以下示例安排邮件以便以后交付的功能

$when = Carbon::now()->addMinutes(10);

Mail::to($request->user())
    ->cc($moreUsers)
    ->bcc($evenMoreUsers)
    ->later($when, new OrderShipped($order));

No further configuration is mentioned in the documentation (no database tables or whatever seem to be required by that feature). 文档中没有提到进一步的配置 (没有数据库表或该功能似乎需要的任何内容)。 But I'm wondering, how does that work ? 但我想知道, 这是怎么回事 Where does Laravel stores the information for later retrieval. Laravel在哪里存储信息以供以后检索。

Is this feature reliable for longer durations? 此功能在较长时间内是否可靠? I want to send a mail to the user 3 days after sign up. 我想在注册后3天向用户发送邮件。 May there be the possibility that the mail gets lost? 可能邮件丢失了吗? For example when restarting the server? 例如,重新启动服务器?

From the same doc you linked 来自您链接的同一个文档

This method will automatically take care of pushing a job onto the queue so the message is sent in the background. 此方法将自动将作业推送到队列,以便在后台发送消息。 Of course, you will need to configure your queues before using this feature. 当然,在使用此功能之前,您需要配置队列。

Laravel uses queues to take care of this. Laravel使用队列来处理这个问题。 You need to enable queuing in the mailable that you're sending. 您需要在您发送的mailable中启用排队。 The mail delayed sending also uses the same queues. 邮件延迟发送也使用相同的队列。 To make use of this feature you need to have a queue setup and a queue listener or worker running to process the queues. 要使用此功能,您需要设置队列设置并运行队列侦听器或工作程序来处理队列。 Check the queues doc for more information on this. 检查队列文档以获取有关此内容的更多信息。

https://laravel.com/docs/5.4/queues https://laravel.com/docs/5.4/queues

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

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