2
我有一個使用laravel 5.4構建的webapp。 現在我開發了一個函數發送給所有用戶一個通信。知道隊列中的郵件是否已發送Laravel 5.4
所以我要創建一個類可郵寄:
class Comunication extends Mailable
{
use Queueable, SerializesModels;
private $data;
private $recipient;
private $fromR;
private $subjectR;
private $template;
public function __construct($template, $data,$recipient,$from,$subject)
{
$this->data = $data;
$this->recipient = $recipient;
$this->fromR = $from;
$this->subjectR = $subject;
$this->viewData = $data;
$this->template = $template;
}
public function build()
{
return $this->from($this->fromR)->to($this->recipient)->subject($this->subjectR)->view($this->template, $this->viewData);
}
而且在我的控制器我有一個函數發送類似:
foreach ($users as $user){
Mail::queue(new Comunication('mail.comunication', array("user"=>"test"), $user->email, '[email protected]', "subject"));
}
而且它的工作原理,並把郵件在我的表喬布斯分貝,但我會知道是否有可能檢查,當我運行時:
php工匠隊列:聽
如果郵件是真實發送或完成失敗的作業。