Just pass an array named data with contents inside data.
The controller
// I'm creating an array with user's info but most likely you can use $user->email or pass $user object to closure later
$user = array(
'email'=>'[email protected]',
'name'=>'Laravelovich'
);
// the data that will be passed into the mail view blade template
$data = array(
'detail'=>'Your awesome detail here',
'name' => $user['name'];
);
// use Mail::send function to send email passing the data and using the $user variable in the closure
Mail::send('emails.welcome', $data, function($message) use ($user)
{
$message->from('[email protected]', 'Site Admin');
$message->to($user['email'], $user['name'])->subject('Welcome to My Laravel app!');
});
Then your view
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
</head>
<body>
<h2>Welcome to my site</h2>
<div>
Your sign up details are below:
</div>
<div>{{ $detail }}</div>
<div>{{ $name}} </div>
</body>
</html>
http://maxoffsky.com/code-blog/sending-e-mail-with-laravel-4-using-mail/
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community