Laravel 5.7队列功能,但不发送电子邮件

时间:2019-07-11 11:52:17

标签: laravel email queue markdown

我已经使用ShouldQueue创建了一个通知,并且填充了我的“工作”表,但是,当我启动命令:“ php artisan queue:listen”时,表中的行已处理但不发送电子邮件。

如果不使用队列,则所有代码功能和电子邮件都会发送到目的地。

我使用降价发送电子邮件。

命令:

namespace App\Console\Commands;

use Illuminate\Console\Command;

//
use Notification;
use App\Notifications\Listini\NotifyListinoUpdate;

class StoreListinoOil extends Command
{
  /**
  * The name and signature of the console command.
  *
  * @var string
  */
  protected $signature = 'command:storelistinooil';

  /**
  * The console command description.
  *
  * @var string
  */


  /**
  * Create a new command instance.
  *
  * @return void
  */
  public function __construct()
  {
    parent::__construct();
  }

  /**
  * Execute the console command.
  *
  * @return mixed
  */
  public function handle()
  {

            $details = array(
              'day_listino' => 'today',
              'email' => 'email@email.com'
            );



            Notification::send($details, new NotifyListinoUpdate($details));


    dd('OK'); 
  }
}

通知-> NotifyListinoUpdate

namespace App\Notifications\Listini;

// use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
// use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
//
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

class NotifyListinoUpdate extends Notification implements ShouldQueue
{
    // use Queueable;
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    private $details;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct($details)
    {
        $this->details = $details;
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return ['mail'];
    }

    /**
     * Get the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \Illuminate\Notifications\Messages\MailMessage
     */
    public function toMail($notifiable)
    {

        return (new MailMessage)
        ->subject('Notifica - '.$this->details['day_listino'])
        ->markdown('mail.admin.listino_update',['details'=> $this->details]);
    }

    /**
     * Get the array representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toArray($notifiable)
    {
        return [
            //
        ];
    }
}

1 个答案:

答案 0 :(得分:0)

您必须使用以下命令运行Queue worker:

WebElement Apply =driver.findElementByXPath("/a[text()[contains(.,' Apply Now ')]]");

查看以下文档:

Running Queue Workers