我一直在努力使Laravel的排隊工作幾個小時,並沒有用我不知道發生了什麼;我認爲隊列正在工作,因爲他們張貼到數據庫,但我不明白的是爲什麼他們不執行並張貼到郵件捕捉。Laravel郵件隊列不張貼到mailtrap
我已經把我的.env
文件database
QUEUE_DRIVER=database
我的控制器:
$mailQueue = (new SendNotification($contact))
->delay(5);
dispatch($mailQueue);
我發送通知任務:
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Mail;
use App\Mail\Notification;
class SendNotification implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $contact;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($contact)
{
$this->contact = $contact;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$notification = (new Notification($contact));
Mail::to('email')
->queue($notification);
}
}
最後,我可郵寄:
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class Notification extends Mailable
{
use Queueable, SerializesModels;
protected $contact;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($contact)
{
$this->contact = $contact;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->view('mail.notify')
->with([
'notifyName' => $this->request->name,
'notifySubject' => $this->request->subject
]);
}
}
真的很基本,但我不明白爲什麼它不發送或發送到Mail陷阱;雖然我的Jobs
表充滿了不會發布的隊列。
有沒有人有過這個問題?如果有的話,任何人都知道解決方案是什麼 - 我試過php artisan queue:work
和php artisan queue:listen
,但他們不會在終端上發佈任何內容。
更新: 我試過php artisan queue:work --queue=high, emails
產量爲
Processing: App\Mail\Notification
,但它仍然沒有發送任何郵件Mailtrap。
您是否檢查了日誌中的錯誤? './ storage/logs/laravel.log' – Pitchinnate