Regenerate Boost guidelines and skills

Generated by boost:update for Boost 2.8, which replaces the pest-testing
skill with testing-best-practices and adds infer-conventions.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017XYnWFt9pJEwvAmNFN38XD
This commit is contained in:
Andreas Reinhold / reini
2026-09-10 10:42:22 +02:00
co-authored by Claude Opus 5
parent 3638455167
commit 92b3b3de56
38 changed files with 1521 additions and 1001 deletions
@@ -1,27 +1,54 @@
# Mail Best Practices
## Implement `ShouldQueue` on the Mailable Class
## Queue Slow Mail Delivery
Makes queueing the default regardless of how the mailable is dispatched. No need to remember `Mail::queue()` at every call site — `Mail::send()` also queues it.
Implement `ShouldQueue` on a mailable when delivery should normally happen in the background. Laravel queues that mailable even when the call site uses `Mail::send()`.
## Use `afterCommit()` on Mailables Inside Transactions
```php
class OrderShipped extends Mailable implements ShouldQueue
{
use Queueable, SerializesModels;
}
```
A queued mailable dispatched inside a transaction may process before the commit. Use `$this->afterCommit()` in the constructor.
Keep mail synchronous when the caller must know immediately whether delivery was accepted, or when no queue worker is available.
## Use `assertQueued()` Not `assertSent()` for Queued Mailables
## Dispatch Queued Mail After Commit
`Mail::assertSent()` only catches synchronous mail. Queued mailables fail `assertSent` with a "Did you mean to use assertQueued()?" hint.
A queued mailable dispatched during a database transaction can be processed before the transaction commits. Call `afterCommit()` on the mailable, or enable the queue connection's `after_commit` option, when the mail depends on committed records.
Incorrect: `Mail::assertSent(OrderShipped::class);` when mailable implements `ShouldQueue`.
```php
Mail::to($user)->send(
(new OrderShipped($order))->afterCommit()
);
```
Correct: `Mail::assertQueued(OrderShipped::class);`
If the transaction rolls back, an after-commit mailable is not dispatched. This setting affects queued mail only; it does not defer synchronous delivery.
## Use Markdown Mailables for Transactional Emails
## Assert the Delivery Mode
Markdown mailables auto-generate both HTML and plain-text versions, use responsive components, and allow global style customization. Generate with `--markdown` flag.
Use `Mail::assertQueued()` for queued mailables and `Mail::assertSent()` for synchronously sent mailables.
## Separate Content Tests from Sending Tests
Incorrect for a mailable that implements `ShouldQueue`:
Content tests: instantiate the mailable directly, call `assertSeeInHtml()`.
Sending tests: use `Mail::fake()` and `assertSent()`/`assertQueued()`.
Don't mix them — it conflates concerns and makes tests brittle.
```php
Mail::assertSent(OrderShipped::class);
```
Correct:
```php
Mail::assertQueued(OrderShipped::class);
```
## Use Markdown Mailables When They Fit
Markdown mailables render HTML and plain-text versions from Laravel's mail components and support publishable themes. They are useful for conventional transactional messages, but a custom HTML and text pair may be more appropriate for a specialized design.
```bash
php artisan make:mail OrderShipped --markdown=mail.orders.shipped
```
## Separate Content and Delivery Tests
Test rendered content by instantiating the mailable and using assertions such as `assertSeeInHtml()` and `assertSeeInText()`. Test delivery separately with `Mail::fake()` and `assertSent()` or `assertQueued()` so failures identify the affected behavior.