PHP – Laravel – Send Eamil

The following php example helps you to send an email into Laravel. 

Code Example:

<?php
// the data will be passed to the mail function
$to = array(
	'email' => "imran@phpmoot.com",
	'name' => "Imran Ali"
);

// the data that will be passed to the view
$data = array(
  'username' => 'imranali',
  'first_name' => 'Imran',
  'link' => 'http://www.phpmoot.com'
);

/* use Mail::send function to send the email
* @params
* 1: name of the view
* 2: data pass to the view
* 3: function allowing us to specify various options on the e-mail message
*/
Mail::send('emails.welcome',
	  $data,
	  function($message) use ($to){
		  $message->to($to['email'], $to['name'])
				  ->subject('Welcome to ABC.com');
		  //$message->getSwiftMessage()->getHeaders()->addTextHeader('Custom-Header-Name', 'value'); // add optional custom header
	  }
);
?>

Post to Twitter Post to Digg Post to Facebook Post to Google Buzz Send Gmail