0
votes

This is the complete error.

Illuminate\Mail\SendQueuedMailable::handle(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "Security\Mail\WelcomeMail" of the object you are trying to operate on was loaded before unserialize() gets called or provide an autoloader to load the class definition in /var/www/html/vendor/laravel/framework/src/Illuminate/Mail/SendQueuedMailable.php

We are using Laravel 5.5. And executing the following code

Mail::to($customer)->queue(new WelcomeMail($customer));

The mailer is the default mailer that comes with laravel, but we're queueing jobs to redis. Customer is a User object. The WelcomeMail is the following

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

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

    public $user;

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

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->view('security::emails.welcome');
    }
}
1
The WelcomeMail gets serialized when put into the queue, then deserialzed when the queue is being processed. Was anything changed to WelcomeMail between serializing and deserialing? Did you rename the class? Did you move the class? Did you change namespaces? Those things can break deserializingPtrTon

1 Answers

0
votes

I figured out what was my problem. It was more than one server (localhost, staging etc... ) had a queue listener on the same Redis instance.