Support the ongoing development of Laravel.io →
Mail Queues
Last updated 1 year ago.
0

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

Thanks, it worked ;)

0

Thank you!

0

Thanks man!

0

Thank you :)

0

In my case was due to defining a closure function in the constructor. Took it out and it worked.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

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

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.