Expand description
Mail sending - Laravel’s Mail::to($user)->send(new WelcomeMail($user)),
re-exported through larust_support::mail (see
crates/larust-support/src/lib.rs) so generated apps depend only on
larust-support, never on this crate directly.
fake’s exports (fake, assert_sent, assert_not_sent, SentMail)
are deliberately not re-exported through larust_support::mail -
they’re testing-only (calling fake() from real app code would
silently and permanently stop that process from ever sending real
mail again). larust-testing reaches them by depending on this crate
directly instead.
Structs§
- Mail
Builder - MailJob
- Framework-owned - fields are
pub(crate), so this is only ever built byMailBuilder::queue, never constructed (or queued) directly by app code.registry.register::<larust_support::mail::MailJob>()is a real registration, no different from any app-definedJob’s - it’s just thatxr new’s scaffold writes that line into every generated app’squeue:workbranch by default, rather than leaving it as a hint the app author must remember to add. - Sent
Mail - A rendered, already-sent (recorded, not dispatched) email - the
output of a
Mailable, not the typed instance itself. Recording the instance would requireMailable: 'static, which would force every Mailable (including the realWelcomeMail<'a>, which borrows itsUser) to own its data instead of borrowing - a breaking constraint this design avoids entirely.
Traits§
- Mailable
- A single email type (Laravel’s Mailable classes) - implemented once
per email the app sends. Both methods are required, with no default
body: a trait-level default would reintroduce the same “silent gap
instead of compile error” failure mode
Policy<U>’s own doc comment already treats as worth avoiding - forgetting to write a real subject or body should fail to compile, not silently send a blank email.
Functions§
- assert_
not_ sent - Panics if any recorded
Msatisfiespredicate. Same lock-then-drop- before-asserting shape asassert_sent, for the same reason. - assert_
sent - Panics unless at least one recorded
Msatisfiespredicate. - fake
- Activates recording - every
send()call for the rest of this process records instead of dispatching (log/smtp), regardless ofmail_driver. Idempotent: a second call in the same process is a no-op (first-writer-wins, matching every other process-wide registry in this codebase -larust_orm::connect(), the route-name registry, the event-listener registry). The recorded list from the first activation keeps accumulating; nothing resets it. - Entry point for Laravel’s
Mail::to($user)->send(new WelcomeMail($user)).