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

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/

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Joe96 joe96 Joined 28 Apr 2014

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.