6

Sane Laravel 5 Mail Example

 4 years ago
source link: http://alexking.org/blog/2015/05/06/laravel-5-mail-example-code
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Sane Laravel 5 Mail Example

May 7, 2015

For some reason, the example code in the Laravel docs for their Mail feature neglect to show how to pass defined variables into the closure. Here is something a little more useful.



<?php

// note, to use $subject within your closure below you have to pass it along in the "use (...)" clause. $subject = 'Welcome!';

Mail::send('emails.welcome', ['key' => 'value'], function($message) use ($subject) { // note: if you don't set this, it will use the defaults from config/mail.php $message->from('[email protected]', 'Sender Name'); $message->to('[email protected]', 'John Smith') ->subject($subject); });


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK