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){
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) {
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

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

sohail5469 replied 1 year ago

Really it's working in that my website at


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

RobertWalker309 replied 1 year ago

Thanks a lot. useful code for me. For more visit Generic Viagra

timadam replied 1 year ago

Greatful for such wonder solution . Code is really very useful.

Demmi22 replied 1 year ago

Nice post! The use of clear tray to organize different accessaries is a very brilliant idea. Viagra Online site

timbroder replied 11 months ago

Thank you! (not viagra spam)

onlinegenericpills replied 11 months ago

Nice post. Thanks!

williamharris83usa replied 5 months ago

Thank you for solving the problem! Recently, I also encountered such a mistake. William H. -

edwardevans83ny replied 4 months ago

Hello everybody! Very cool forum you have, there is a lot of useful information. Thanks! (Edward E. - )

Sign in to participate in this thread!

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