Skip to content

Commit 7cb184f

Browse files
[6.x] Allow easier customization of the queued mailable job (#31684)
* Allow easier customization of the queued mailable job. This will allow developers to override this makeQueuedJob method in their mailables and return their own job - which means we can enable job middlewares rate limiting etc easily for all mailables. * Update Mailable.php Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent 83f4410 commit 7cb184f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/Illuminate/Mail/Mailable.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public function queue(Queue $queue)
177177
$queueName = property_exists($this, 'queue') ? $this->queue : null;
178178

179179
return $queue->connection($connection)->pushOn(
180-
$queueName ?: null, new SendQueuedMailable($this)
180+
$queueName ?: null, $this->newQueuedJob()
181181
);
182182
}
183183

@@ -195,10 +195,20 @@ public function later($delay, Queue $queue)
195195
$queueName = property_exists($this, 'queue') ? $this->queue : null;
196196

197197
return $queue->connection($connection)->laterOn(
198-
$queueName ?: null, $delay, new SendQueuedMailable($this)
198+
$queueName ?: null, $delay, $this->newQueuedJob()
199199
);
200200
}
201201

202+
/**
203+
* Make the queued mailable job instance.
204+
*
205+
* @return mixed
206+
*/
207+
protected function newQueuedJob()
208+
{
209+
return new SendQueuedMailable($this);
210+
}
211+
202212
/**
203213
* Render the mailable into a view.
204214
*

0 commit comments

Comments
 (0)