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');
}
}
WelcomeMail
gets serialized when put into the queue, then deserialzed when the queue is being processed. Was anything changed toWelcomeMail
between serializing and deserialing? Did you rename the class? Did you move the class? Did you change namespaces? Those things can break deserializing – PtrTon