Hey everyone,
When I try using Mail::queue() I get this error:
ErrorException in SerializableClosure.php line 93:
Serialization of closure failed: Serialization of 'Closure' is not allowed
Any ideas why? Here is the method I use in my own Mailer abstract class:
public function send()
{
return $this->mailer->queue($this->view, $this->data, function($message){
$message->to($this->to)->subject($this->subject);
});
}
Well turns out I just solved it myself. For future reference the issue is using $this inside of the closure.
$this->to and $this->subject are references to fields on the Class and not in the Closure so to fix the code I had to make them local variables and pass them to my closure like so:
public function send()
{
$to = $this->getTo();
$subject = $this->getSubject();
return $this->mailer->queue($this->getView(), $this->getData(), function($message) use($to, $subject) {
$message->to($to)->subject($subject);
});
}
In my case was due to defining a closure function in the constructor. Took it out and it worked.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community