Skip to content

[13.x] Support DeleteWhenMissingModels and FailOnTimeout on queued mailables - #61899

Merged
taylorotwell merged 2 commits into
laravel:13.xfrom
xurshudyan:mailable-delete-missing-models-fail-on-timeout
Oct 7, 2026
Merged

taylorotwell merged 2 commits into
laravel:13.xfrom
xurshudyan:mailable-delete-missing-models-fail-on-timeout

Conversation

@xurshudyan

Copy link
Copy Markdown
Contributor

Queued mailables ignore #[DeleteWhenMissingModels] and #[FailOnTimeout] (and the $deleteWhenMissingModels / $failOnTimeout properties), because SendQueuedMailable doesn't copy them from the mailable.

#[DeleteWhenMissingModels]
class OrderShipped extends Mailable implements ShouldQueue
{
    use Queueable, SerializesModels;

    public function __construct(public Order $order) {}
}

Mail::to($user)->later(now()->addMinutes(15), new OrderShipped($order));

If the order is deleted before the mail is sent, the job fails with a ModelNotFoundException and ends up in failed_jobs instead of being deleted. With #[FailOnTimeout], a mail that timed out on a slow SMTP server is retried anyway, so the customer can get it twice.

@taylorotwell
taylorotwell merged commit aec7a75 into laravel:13.x Oct 7, 2026
64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants