Skip to content

[13.x] Support #[Delay] attribute on queued mailables#59580

Merged
taylorotwell merged 1 commit intolaravel:13.xfrom
sumaiazaman:fix/mailable-delay-attribute-v2
Apr 7, 2026
Merged

[13.x] Support #[Delay] attribute on queued mailables#59580
taylorotwell merged 1 commit intolaravel:13.xfrom
sumaiazaman:fix/mailable-delay-attribute-v2

Conversation

@sumaiazaman
Copy link
Copy Markdown
Contributor

Summary

The #[Delay] attribute is supported for queued jobs (Bus\Dispatcher), event listeners (Events\Dispatcher), and notifications (NotificationSender), but queued mailables only check the $delay property and ignore the attribute entirely.

This means the following does not work as expected:

use Illuminate\Queue\Attributes\Delay;

#[Delay(30)]
class WelcomeEmail extends Mailable implements ShouldQueue
{
    // The #[Delay] attribute is ignored — mailable is queued immediately
}

Changes

  • Added ReadsClassAttributes support trait to Mailable
  • Updated Mailable::queue() to use getAttributeValue() for reading delay, consistent with how Bus\Dispatcher::pushCommandToQueue(), Events\Dispatcher::queueHandler(), and NotificationSender::queueNotification() handle the #[Delay] attribute
  • The $delay property still takes precedence when explicitly set (not default), matching the behavior of getAttributeValue()

Follows up on #59577 with the suggested change to use the support trait.

Test Plan

  • Added test to verify #[Delay] attribute is respected on queued mailables
  • Added test to verify property override still takes precedence over attribute
  • Existing queued mailable tests still pass

The #[Delay] attribute is supported for queued jobs, event listeners,
and notifications, but queued mailables only check the $delay property
and ignore the attribute entirely.

This adds the ReadsClassAttributes support trait to Mailable and uses
getAttributeValue() in the queue() method, consistent with how
Bus\Dispatcher, Events\Dispatcher, and NotificationSender handle
the #[Delay] attribute.
@taylorotwell taylorotwell merged commit 96613ec into laravel:13.x Apr 7, 2026
54 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