1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//! Send email through Resend, Amazon SES, or a transport of your own.
//!
//! Most applications email their users, with an order confirmation or a password reset link. A
//! [`Mailable`] builds a [`Message`]. `mail::to` names the recipients, and `send`, `queue`, or
//! `send_background` sends it:
//!
//! ```no_run
//! use laravel::mail::{self, Mailable, Message};
//! use laravel::view::{data, view};
//!
//! struct OrderShipped { order_id: u64 }
//!
//! impl Mailable for OrderShipped {
//! fn build(&self) -> laravel::Result<Message> {
//! Ok(Message::new()
//! .subject(format!("Order #{} has shipped", self.order_id))
//! .view(view("mail.order-shipped", data! { order_id => self.order_id })))
//! }
//! }
//!
//! # async fn example() -> laravel::Result<()> {
//! mail::to("taylor@laravel.com").send(OrderShipped { order_id: 42 }).await?;
//! mail::to("taylor@laravel.com").queue(OrderShipped { order_id: 42 }).await?;
//! mail::to("taylor@laravel.com").send_background(OrderShipped { order_id: 42 })?;
//! # Ok(()) }
//! ```
//!
//! Each send renders the message into an [`Email`] before it returns, so a view that fails to
//! render or an invalid address fails the send. Named mailers choose the transport. The
//! `MAIL_MAILER` variable selects the default. The [mail guide] covers configuration, mail views,
//! and testing with [`fake`](fake()).
//!
//! # Tracing
//!
//! Laravel traces mail for every transport:
//!
//! | Span | Attributes |
//! | --- | --- |
//! | `mail.render`, for each `send`, `send_background`, `queue`, and `render` | `mail.mailable`, the mailable's type name, and `mail.message.id` |
//! | `mail.send`, for each transport call | `mail.mailer`, `mail.transport`, `mail.message.id`, `mail.recipients` as a count, and `mail.provider.message_id` when the provider returns one. An error marks the span as failed |
//!
//! Spans carry IDs and counts, not addresses, subjects, or bodies. A failover mailer adds a
//! `mail.send` span for each mailer it tries. Each successful send also writes a `debug` line under
//! the `laravel::mail` target, with the mailer, the email's ID, and the provider's message ID.
//!
//! [mail guide]: https://github.com/laravel/rust-framework/blob/0.x/docs/mail.md
pub use *;
pub use ;