Skip to content

Instantly share code, notes, and snippets.

@wouterj
Created June 9, 2014 09:04
Show Gist options
  • Select an option

  • Save wouterj/f9892fc00d7d2a672fb6 to your computer and use it in GitHub Desktop.

Select an option

Save wouterj/f9892fc00d7d2a672fb6 to your computer and use it in GitHub Desktop.
<?php
Route::get('/hello-mail/{name}', function ($name) {
Mail::send('emails.hello', array('name' => $name), function ($message) {
$message->to('foo@example.com', 'Foo')->subject('Someone visited /hello-mail/');
});
});
<?php
Route::get('/hello-mail/{name}', 'MailController@sendHello');
class MailController extends BaseController
{
private $mailer;
// $mailer get automatically resolved by the IoC container
public function __construct(\Illuminate\Mail\Mailer $mailer)
{
$this->mailer = $mailer;
}
public function sendHello($name)
{
$this->mailer->send('emails.hello', array('name' => $name), function ($message) {
$message->to('foo@example.com', 'Foo')->subject('Someone visited /hello-mail/');
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment