Forum

Serialization of closure failed: Serialization of 'Closure' is not allowed

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);
    });
}
Jamesking56
Jamesking56
  • 2 years ago

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);
    });
}

Thanks, it worked ;)

Thank you!

Diese Ausschnitte sind wirklich arbeiten, große!! Kamagra http://www.dragonapotheke.com/

Well turns out I simply tackled it myself. For future reference the issue is utilizing $this within the conclusion.... Checkout my blog post Viagra http://www.pharmacyglobalrx.com/

Really it's working in that my website at http://www.ownow.com

thanks

Thanks man!

Thank you :)

Thank you very much for the information. I have a website written about viagra http://achetermedic.com

Thanks a lot. useful code for me. For more visit Generic Viagra http://www.genericapharmacy.net/

Greatful for such wonder solution . Code is really very useful. http://www.simplyviagra.com/product/generic-viagra

Nice post! The use of clear tray to organize different accessaries is a very brilliant idea. Viagra Online site http://www.doctors-medicine.com/viagra-pills.html

Thank you! (not viagra spam)

Nice post. Thanks! http://www.onlinegenericpills.co/product/careprost

Thank you for solving the problem! Recently, I also encountered such a mistake. William H. - http://ahealthgroup.net/viagra-123.com/