I'm getting a "Undefined variable: data" error whenever this function runs. The $data variable is definitely defined in the method calling this function so I'm not entirely sure why I'm getting this error. Any ideas?
public function email($data)
{
Mail::queue(array('text' => 'emails.plaintext'), $data, function($message)
{
$message->from('my@email.co.za', 'My Name');
$message->to($data['email'])->subject('Email Subject');
});
}
I've tried adding $data to the function set as the 3rd parameter which hasn't helped
Mail::queue(array('text' => 'emails.plaintext'), $data, function($message, $data)
{
$message->from('my@email.co.za', 'My Name');
$message->to($data['email'])->subject('Email Subject');
});
I've also tried defining a new variable for the email which hasn't worked either
$email = $data['email'];
Mail::queue(array('text' => 'emails.plaintext'), $data, function($message)
{
$message->from('my@email.co.za', 'My Name');
$message->to($email)->subject('Email Subject');
});
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community