Framework: class SetQueue not found origination from the Mail facade

Created on 16 Oct 2018  路  13Comments  路  Source: laravel/framework

Hi all,

Can anyone shed some light on why the Mail facade is spewing out that a certain SetQueue class cannot be found? I haven't changed anything code wise, it weirdly started happening overnight.

I've tried to clear my composer cache and reinstall all the repositories and dumped the auto-load etc but I can't seem to get it working 馃憥 .

Anyone else having the same problem or experienced this?

The traceback can be found here.

needs more info

All 13 comments

Hi there,

Looks like this is a question which can be asked on a support channel. Please only use this issue tracker for reporting bugs or problems. If you have a question on how to use functionality provided by this repo you can try one of the following channels:

@Cranavvo I'm having this same issue after updating to PHP 7.3. I have no changes in the codebase. I've tried changing the MAIL_DRIVER and QUEUE_CONNECTION env vars, but nothing seems to work.

Did you find a solution?

@patrickomeara same here after upgrading to PHP 7.3

Okay I'll have a look at this. I'll need more info and/or code to debug this further. Please post relevant code like models, jobs, commands, notifications, events, listeners, controller methods, routes, etc. You may use https://paste.laravel.io to post larger snippets or just reply with shorter code snippets. Thanks!

To give it a little more context. It concerns an app that was updated from Laravel 5.5 to 5.7. PHP has been updated from 7.1 to 7.3.

I changed QUEUE_DRIVER to QUEUE_CONNECTION. The config is cleared / cached at every deploy.

It's odd that sometimes it works (same model, same mail) without any problems. I thought it might have something to do with OPcache. So now I also clear the OPcache with a command (opcache_reset()) after every deploy, in addition to the FPM restart from the envoyer script.

Here is an error message: https://paste.laravel.io/0603b738-da94-452f-bc73-a54cdde4398f

Which queue connection are you using? Did you modify the queue config from the base laravel skeleton? Can you post the code of the NewsflowController and the NewsflowArticle classes? Are you overwriting the Mailer class? Are you using macros on the Mailer class?

I am using redis (horizon). I updated the config/queue.php file with the latest changes from Laravel 5.7. No macros or changes to the Mailer class.

NewsflowController

<?php

namespace App\Http\Controllers;

use App\Models\NewsflowArticle;
use App\Models\NewsflowSubscription;
use Illuminate\Support\Facades\Mail;
use App\Mail\Newsflow\NewsflowNotification;

class NewsflowController extends Controller
{
    ///
    ///

    protected function sendPushNotifications(NewsflowArticle $article)
    {
        $subscriptions = NewsflowSubscription::where('confirmed', true)->where('interval', 'push')->get();

        foreach ($subscriptions as $subscription) {
            Mail::to($subscription->email)->send(new NewsflowNotification($subscription, 'push', $article));
        }
    }

NewsflowArticle and NewsflowSubscription are just two base Eloquent Models without any modification.

App\Mail\Newsflow\NewsflowNotification.php

<?php

namespace App\Mail\Newsflow;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class NewsflowNotification extends Mailable implements ShouldQueue
{
    use Queueable, SerializesModels;

    public $subscription;

    public $article;

    public $interval;

    public function __construct($subscription, $interval, $article)
    {
        $this->subscription = $subscription;

        $this->interval = $interval;

        $this->article = $article;
    }

    public function build()
    {
        return $this->view('emails.newsflow.notification');
    }
}

Did you restart horizon and purged any orphan processes with horizon:purge?

I'm not using queues of any sort in my application... my _shitty_ solution was opening up the MailServiceProvider in Laravel (vendor/laravel) and commenting out this:

if ($app->bound('queue')) {
     $mailer->setQueue($app['queue']);
}

I'm still cursed to this day, an error will trigger every time to Mail facade is used (if the code above isn't commented out).

Yes, with the following after each deploy:

php artisan horizon:purge
php artisan horizon:terminate

I'm actually pretty sure it has nothing to do with the framework itself. It's just very strange that it happened so suddenly after upgrading to PHP 7.3. Had no problem the whole day with this error and the mails were sent without problems. Just now the error occurred again. After I restarted nginx, everything works again.

I'm going to close this off then if this problem was resolved. Could have been a hiccup with the upgrade to 7.3? Let me know if the problem persists.

For MacBook Users just use command "valet restart" In my case, it's working now. Try to restart your server that might be helpful.

Was this page helpful?
0 / 5 - 0 ratings