[英]Laravel mail queue not posting to mailtrap
I've been trying to make Laravel's Queuing work for hours and to no avail I have not Idea what's going on; 我一直在努力使Laravel的Queuing工作数小时,但无济于事,我不知道发生了什么事。 I think the queues are working since they are posting to the database but what I don't understand is why aren't they executing and posting to mailtrap.
我认为队列正在工作,因为它们正在发布到数据库,但是我不明白的是为什么它们不执行并发布到邮件陷阱。
I've set my .env
file to database
我已将
.env
文件设置为database
QUEUE_DRIVER=database
My controller: 我的控制器:
$mailQueue = (new SendNotification($contact))
->delay(5);
dispatch($mailQueue);
My Send Notification Job: 我的发送通知作业:
<?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);
}
}
Finally, my Mailable: 最后,我的Mailable:
<?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
]);
}
}
Pretty basic really, but I don't understand why its not posting or sending to Mail trap; 确实很基本,但是我不明白为什么它不发布或发送到邮件陷阱; although my
Jobs
table is filled with Queues that won't post. 尽管我的
Jobs
表充满了不会发布的队列。
Has anyone ever had this problem? 有人遇到过这个问题吗? if so anyone know what the solution is - I tried
php artisan queue:work
and php artisan queue:listen
but they don't post anything out on terminal. 如果有人知道解决方案是什么-我尝试了
php artisan queue:work
和php artisan queue:listen
但他们没有在终端上发布任何内容。
UPDATE: I tried php artisan queue:work --queue=high, emails
the output was 更新:我尝试了
php artisan queue:work --queue=high, emails
了输出
Processing: App\\Mail\\Notification
but it still didn't send any mail to Mailtrap. 但它仍然没有向Mailtrap发送任何邮件。
Doesn't look like you have a public function via()
set in your Notification. 看起来您没有在Notification中设置的
public function via()
。 You need to specify how you want the notification to be delivered. 您需要指定希望通知的发送方式。
public function via($notifiable)
{
return ['mail'];
}
Also Notifications normally extend Illuminate\\Notifications\\Notification
. 另外,通知通常会扩展
Illuminate\\Notifications\\Notification
。
Nevermind looks like you aren't using the built in notification system. 没关系,您好像没有使用内置的通知系统。 My guess is the problem is with this:
我的猜测是这个问题:
$mailQueue = (new SendNotification($contact))
->delay(5);
If you look in the documentation it passes a Carbon object into the delay. 如果您查看文档,则会将Carbon对象传递给延迟。
$job = (new ProcessPodcast($podcast))
->delay(Carbon::now()->addMinutes(10));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.