29.07.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 296<br />

.<br />

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

2 //<br />

3 });<br />

This method will automatically take care of pushing a job onto the queue to send the mail message<br />

in the background. Of course, you will need to configure your queues before using this feature.<br />

Delayed Message Queueing<br />

If you wish to delay the delivery of a queued e-mail message, you may use the later method. To get<br />

started, simply pass the number of seconds by which you wish to delay the sending of the message<br />

as the first argument to the method:<br />

.<br />

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

2 //<br />

3 });<br />

Pushing To Specific Queues<br />

If you wish to specify a specific queue on which to push the message, you may do so using the<br />

queueOn and laterOn methods:<br />

.<br />

1 Mail::queueOn('queue-name', 'emails.welcome', $data, function ($message) {<br />

2 //<br />

3 });<br />

4<br />

5 Mail::laterOn('queue-name', 5, 'emails.welcome', $data, function ($message) {<br />

6 //<br />

7 });<br />

Mail & Local Development<br />

When developing an application that sends e-mail, you probably don’t want to actually send e-mails<br />

to live e-mail addresses. Laravel provides several ways to “disable” the actual sending of e-mail<br />

messages.

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

Saved successfully!

Ooh no, something went wrong!