mail message sending delay

This commit is contained in:
salam committed 2026-05-12 08:40:46 +02:00
1 parent 1963d6fcce
commit dae8336ac9
2 files changed
+15 -3

No files matched your search

+8 -2
View File
@@ -13,12 +13,15 @@ class SendNewsletterJob implements ShouldQueue
public $data;
public $delay;
/**
* Create a new job instance.
*/
public function __construct($data)
public function __construct($data, $delay = 0)
{
$this->data = $data;
$this->delay = $delay;
}
/**
@@ -27,6 +30,9 @@ class SendNewsletterJob implements ShouldQueue
*/
public function handle(): void
{
Mail::to($this->data['email'])->send(new Newsletter($this->data));
// Mail::to($this->data['email'])->send(new Newsletter($this->data));
Mail::to($this->data['email'])->later(now()->addSeconds($this->delay), new Newsletter($this->data));
}
}