如何在完成一系列排队作业后发送电子邮件(Laravel 5.5)?

时间:2017-09-22 15:46:11

标签: laravel notifications jobs laravel-5.5

在我的一系列工作完成后向用户发送电子邮件通知的最佳方法是什么?

我正在使用Laravel 5.5&地平线排队。

我的方法是验证用户并触发一系列作业:

        public function activateUser($token)
        {
            if ($user = $this->activationService->activateUser($token)) {


                CheckIfDown::withChain([
     (new ScanOne($user))->onQueue('new-user'),
     (new ScanTwo($user))->onQueue('new-user'),
     (new ScanThree($user))->onQueue('new-user'),
     (new FirstScanFinished($user))->onQueue('new-user') // What I've tried - this job should send an email from it's handle() method.

                ])->dispatch($user)->onQueue('new-user');


                return redirect('/login')->with('message', 'You have successfully completed the registration process!');
                //            return redirect($this->redirectPath());
            }
            abort(404);
        }

只有在用户验证其电子邮件地址后,才会触发这些特定的作业链。电子邮件只能发送一次。

FirstScanFinished句柄方法

public function handle()
{
    $message = (new FirstScanFinished($this->user));
    $email = $this->user->email;
    Mail::to($email)
        ->send($message);
}

所有工作似乎都被成功解雇了,但我的邮件收集中没有收到任何电子邮件(只是为了记录我的所有smtp设置都很好,其他地方的电子邮件都没有任何问题)。我也没有在日志中收到任何错误。我该怎么做呢?

0 个答案:

没有答案
相关问题