This is weird. I am sure I am missing something simple. I have the following code:
$productToken = Input::get('key');
$products = new Product;
$userEmail = $products->activateProduct($productToken);
$productDetailsArray = $products->getProductDetailsForUserEmail($productToken);
$emailData = $productDetailsArray;
Mail::send('emails.productReleased', $emailData, function($message){
$message->to($userEmail)->subject('Notification - Your Product was Released to the Public!');
});
It is supposed to activate the product in the database and then send email to user. The email of the user is in the $userEmail and when I did var_dump, it shows. Somehow this line throws an error that $userEmail is undefined:
$message->to($userEmail)->subject('Notification - Your Product was Released to the Public!');
This is the error I get:
Undefined variable: userEmail
I used Mail function before but instead of passing variable I passed the Input::get('email') because it was in a registration form. Right now, I don't have access to the Input but rather $userEmail. Please advise.