This is default simple documentation of #laravel to send mail but problems is that this is static mail passed in parameter to(‘foo@sdtuts.com’)
Mail::send('emailtemplate_view', ['data' => 'for_emailtemplate_view'], function($message){ $message->to('foo@sdtuts.com', 'SDTuts')->subject('Welcome!'); });
We also need to pass the dynamic email, for example we used it for user registration steps to sent mail for activation it that time we need dynamic email address not static.
here is code example to use variable in laravel mail method.
$mail_sendinfo = array( 'user_email'=>Input::get('user_email'), 'mail_subject'=>'User registration confirmation!', 'user_name'=>'Rameez Soomro' ); Mail::send('emailtemplate_view', ['data' => 'for_emailtemplate_view'], function($message) use($mail_sendinfo) { $message->to($mail_sendinfo['user_email'], $mail_sendinfo['user_name'])->subject($mail_sendinfo['mail_subject']); });