php - Laravel mail function - scope issue? -
i'm using laravel's mail function send user's confirmation email. problem is, i'm getting error "undefined variable: email"
this code:
$email="someemail@gmail.com"; $name="thename"; \mail::send('emails.verify', ['confirmation_code' => $user->confirmation_code], function($message) { $message->from('myemail@myserver.com', 'confirmation')->to($email, $name)->subject('please verify email address'); });
apparently declared variables $email , $name not on same scope $message->from.. being called..
any ideas on how solve this?
you should use use
statement in closure "include" $email
, $name
variable:
\mail::send('emails.verify', ['confirmation_code' => $user->confirmation_code], function($message) use ($email, $name) { $message->from('myemail@myserver.com', 'confirmation') ->to($email, $name) ->subject('please verify email address'); } );
Comments
Post a Comment