Back

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


Jamesking56 posted 2 years ago

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 replied 2 years ago Solution

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);
	});
}
victorboissiere replied 2 years ago

Thanks, it worked ;)

vahid1324 replied 2 years ago

Thank you!

JensSvenson replied 2 years ago

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

JosephMurrell replied 2 years ago

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/

sohail5469 replied 2 years ago

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

thanks

kkiernan replied 1 year ago

Thanks man!

dsampaolo replied 1 year ago

Thank you :)

Jerry7892 replied 1 year ago

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

RobertWalker309 replied 1 year ago

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

timadam replied 1 year ago

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

Demmi22 replied 1 year ago

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

timbroder replied 1 year ago

Thank you! (not viagra spam)

onlinegenericpills replied 1 year ago

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

williamharris83usa replied 7 months ago

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

edwardevans83ny replied 6 months ago

Hello everybody! Very cool forum you have, there is a lot of useful information. Thanks! (Edward E. - http://canadianmedicines.net/cialis.html )


Sign in to participate in this thread!



We'd like to thank these amazing companies for supporting us