Skip to content

Commit 9cc3be1

Browse files
committed
Add docs for #106
1 parent edccbb9 commit 9cc3be1

File tree

1 file changed

+40
-5
lines changed

1 file changed

+40
-5
lines changed

docs/en/index.rst

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,10 @@ Job Properties:
178178
example, refreshing calculated data. If ``true``, the ``uniqueCache``
179179
configuration must be set.
180180

181-
Queueing
182-
--------
181+
Queueing Jobs
182+
-------------
183183

184-
Queue the messages using the included `Queue\QueueManager` class::
184+
You can enqueue jobs using ``Cake\Queue\QueueManager``::
185185

186186
use App\Job\ExampleJob;
187187
use Cake\Queue\QueueManager;
@@ -239,8 +239,8 @@ The following keys are valid for use within the ``options`` array:
239239
- description: The name of a queue to use
240240
- type: string
241241

242-
Queuing Mailer Actions
243-
----------------------
242+
Queueing Mailer Actions
243+
-----------------------
244244

245245
Mailer actions can be queued by adding the ``Queue\Mailer\QueueTrait`` to the
246246
mailer class. The following example shows how to setup the trait within a mailer
@@ -287,6 +287,41 @@ The exposed ``QueueTrait::push()`` method has a similar signature to
287287
options this array holds are the same options as those available for
288288
``QueueManager::push()``.
289289

290+
Delivering E-mail via Queue Jobs
291+
--------------------------------
292+
293+
If your application isn't using Mailers but you still want to deliver email via
294+
queue jobs, you can use the ``QueueTransport``. In your application's
295+
``EmailTransport`` configuration add a transport::
296+
297+
// in app/config.php
298+
use Cake\Queue\Mailer\Transport\QueueTransport;
299+
300+
return [
301+
// ... other configuration
302+
'EmailTransport' => [
303+
'queue' => [
304+
'className' => QueueTransport::class,
305+
// The transport to use inside the queue job.
306+
'transport' => MailTransport::class,
307+
'config' => [
308+
// Configuration for MailTransport.
309+
]
310+
]
311+
],
312+
'Email' => [
313+
'default' => [
314+
// Connect the default email profile to deliver
315+
// by queue jobs.
316+
'transport' => 'queue',
317+
]
318+
]
319+
];
320+
321+
With this configuration in place, any time you send an email with the ``default``
322+
email profile CakePHP will generate a queue message. Once that queue message is
323+
processed the ``MailTransport`` will be used to deliver the email messages.
324+
290325
Run the worker
291326
==============
292327

0 commit comments

Comments
 (0)