Tongi
Tongi

Reputation: 51

Sending an email in laravel 4.2

Hei, am trying to send am email in laravel 4.2 to the registered users in my application but am getting an error i dont know how to go about it here is my function

 Mail::send('emails.email',array('user'=>$user), function($message)
        {
            $message->to(Input::get('email'),Input::get('first_name'))->subject('Thank You for Joining bagagga Savings Club');
        });

Upvotes: 1

Views: 90

Answers (1)

Wouter Van Damme
Wouter Van Damme

Reputation: 781

This is how i normally do it.

$email =  Input::get('email');
$first-name = Input::get('first_name');

Mail::send('emails.email',array('user'=>$user), function($message) use ($email , $first_name)
{
        $message->to($email,$first_name)->subject('Thank You for Joining bagagga Savings Club');
});

To pass a variable to an anonymous function, you can use the use construct.

Upvotes: 1

Related Questions