How does Laravel send out emails for later sending?

Laravel Documentation describes the ability to schedule mail for future delivery , in the following example:

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

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

No additional configuration is mentioned in the documentation (there are no database tables for this function or something like that). But I wonder how it works ? Where Laravel stores information for later retrieval.

Is this feature reliable for longer periods of time? I want to send a letter to the user 3 days after registration. Is it possible that mail will be lost? For example, when you restart the server?

+6
source share
1 answer

From the same document you linked

This method will automatically take care of completing the task so that 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. You need to turn on the priority in the mail you send. Postponed mail also uses the same queues. To use this feature, you need to configure the queue and the queue listener, or the worker that processes the queues. For more information about this, check out the dows doc.

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

+8
source

Source: https://habr.com/ru/post/1017293/


All Articles