【发布时间】:2019-07-17 23:36:18
【问题描述】:
我正在尝试在触发事件时实现电子邮件通知。当一个事件被触发时,监听器将触发一个电子邮件通知。
当我没有实现队列时发送电子邮件。如果我实施了队列方法,则不会发送电子邮件。
当我运行队列工作者时,它给了我以下输出。但是没有发送电子邮件。
[2019-02-24 11:10:25] Processing: App\Notifications\CustomRequestListener
[2019-02-24 11:10:25] Processed: App\Notifications\CustomRequestListener
我已经配置了如下的监听器、事件、通知。
听众
class CustomRequestListener
{
public function handle(CustomRequestCreated $event)
{
$user->notify(new CustomRequestEmail());
}
}
通知类
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
class CustomRequestEmail extends Notification implements ShouldQueue
{
use Queueable;
public function via($notifiable)
{
return ['mail'];
}
public function toMail($notifiable)
{
return (new MailMessage)
->subject('Test Mail')
->view('layout.testmail.template');
}
}
queue.php
'default' => env('QUEUE_DRIVER', 'database'),
'连接'=> [
'sync' => [
'driver' => 'sync',
],
'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'retry_after' => 90,
],
.env
QUEUE_DRIVER=database
【问题讨论】: