06.10.2016 Views

laravel-5

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Mail 400<br />

25 $m->from('hello@app.com', 'Your Application');<br />

26<br />

27 $m->to($user->email, $user->name)->subject('Your Reminder!');<br />

28 });<br />

29 }<br />

30 }<br />

Since we are passing an array containing the user key in the example above, we could display the<br />

user’s name within our e-mail view using the following PHP code:<br />

1 <br />

Note: A $message variable is always passed to e-mail views, and allows the inline<br />

embedding of attachments. So, you should avoid passing a message variable in your view<br />

payload.<br />

Building The Message<br />

As previously discussed, the third argument given to the send method is a Closure allowing you<br />

to specify various options on the e-mail message itself. Using this Closure you may specify other<br />

attributes of the message, such as carbon copies, blind carbon copies, etc:<br />

1 Mail::send('emails.welcome', $data, function ($message) {<br />

2 $message->from('us@example.com', 'Laravel');<br />

3<br />

4 $message->to('foo@example.com')->cc('bar@example.com');<br />

5 });<br />

Here is a list of the available methods on the $message message builder instance:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!