Support the ongoing development of Laravel.io →
posted 9 years ago
Mail
Last updated 2 years ago.
0
Solution

Because you are in a closure, or function, variables declared outside of the function are not available to you, this is the same as how standard PHP works where you'd need to declare global $variable to get access to your variables that are declared outside the scope of your function.

To access variables inside a closure you can use the following.

Mail::queue('emails.order', $data, function($message) use ($email, $ename)
{
    $message->from('[email protected]', 'Denis Romanenko'); $message->to($email, $ename)->subject("Your order");
});
Last updated 2 years ago.
0

iWader, thank you very much, nice explanation for unskilled programmer like me :)

Last updated 2 years ago.
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.