pub struct MailBuilder { /* private fields */ }Implementations§
Source§impl MailBuilder
impl MailBuilder
Sourcepub fn to(self, email: impl Into<String>) -> MailBuilder
pub fn to(self, email: impl Into<String>) -> MailBuilder
Adds a recipient - callable more than once for multiple recipients.
Sourcepub async fn send<M>(self, mailable: M) -> Result<(), AppError>where
M: Mailable,
pub async fn send<M>(self, mailable: M) -> Result<(), AppError>where
M: Mailable,
Sends mailable to every address given to to(...) so far.
If crate::fake::fake() has been called anywhere in this process,
this records the rendered subject/body/recipients instead of
dispatching at all - checked before mail_driver is even read,
so Mail::fake() overrides log/smtp regardless of configuration,
matching Laravel’s own Mail::fake(). Otherwise dispatches on
mail_driver via [deliver] - see Self::queue for the
deferred-delivery sibling of this method.
Sourcepub async fn queue<M>(self, mailable: M) -> Result<(), AppError>where
M: Mailable,
pub async fn queue<M>(self, mailable: M) -> Result<(), AppError>where
M: Mailable,
Enqueues mailable for asynchronous delivery instead of sending it
immediately - Laravel’s Mail::to($user)->queue(new WelcomeMail($user)).
Mailable deliberately has no Serialize/'static bound (the real
WelcomeMail<'a> in demo/app/Mail/welcome_mail.rs borrows), so
this can’t serialize the typed mailable itself the way an
app-defined larust_queue::Job would. Instead it renders
subject()/html_body() eagerly, synchronously, right here -
the exact same rendering send() already does - and enqueues only
the already-rendered {to, subject, html_body} via the
framework-owned crate::MailJob. This is a deliberate,
documented deviation from Laravel: Laravel’s Mail::queue(...)
stores a serialized reference to the mailable’s own data and
re-renders fresh on the worker at send time (so DB changes between
queue-time and send-time are reflected, and rendering work moves
off the request thread); this implementation defers delivery
(the SMTP/network I/O) but not rendering - the HTML is frozen at
the moment .queue() is called. Replicating Laravel’s
re-resolve-on-worker behavior would need a SerializesModels-style
generic model-lookup mechanism this framework doesn’t have.
Respects Mail::fake() exactly like send() does - a faked
.queue() call records into the same SentMail list send()
uses (there’s no separate assertQueued concept yet; see
docs/ARCHITECTURE.md’s Mail section) and never touches the real
queue.
xr new’s scaffold registers larust_support::mail::MailJob in
every generated app’s queue:work branch by default, so queued
mail works out of the box - but it’s still a plain, real
registration line an app can remove, not runtime magic. An app
that removes it (or was scaffolded before this default existed)
sees an unregistered MailJob land in failed_jobs, the same
failure mode as any other unregistered job type.
Auto Trait Implementations§
impl Forget for MailBuilder
impl Freeze for MailBuilder
impl Move for MailBuilder
impl RefUnwindSafe for MailBuilder
impl Send for MailBuilder
impl Sync for MailBuilder
impl Unpin for MailBuilder
impl UnsafeUnpin for MailBuilder
impl UnwindSafe for MailBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more