#[non_exhaustive]pub struct Mail {
pub to: Vec<String>,
pub subject: String,
pub text: String,
pub html: Option<String>,
pub cc: Vec<String>,
pub bcc: Vec<String>,
pub reply_to: Option<String>,
pub from: Option<String>,
pub attachments: Vec<Attachment>,
}Expand description
One email message. html is optional; text is always sent.
let pdf: Vec<u8> = b"%PDF-1.7 ...".to_vec();
let mail = Mail::new("ben@example.com", "Invoice INV-001", "Your invoice is attached.")
.also_to("finance@example.com")
.cc("sales@example.com")
.bcc("archive@example.com")
.reply_to("Coffee Shop <hello@shop.example>")
.from("Coffee Shop Billing <billing@shop.example>") // instead of MAIL_FROM_*
.attach("INV-001.pdf", "application/pdf", pdf);Addresses are a@b.c or Name <a@b.c>; an invalid one fails the send
(and a queued mail isn’t retried for it).
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.to: Vec<String>Recipients.
subject: StringThe subject line.
text: StringThe plain-text body.
html: Option<String>An HTML body, sent next to text when set.
cc: Vec<String>Carbon-copy recipients.
bcc: Vec<String>Blind-carbon-copy recipients.
reply_to: Option<String>The address replies go to.
from: Option<String>Sender instead of MAIL_FROM_ADDRESS / MAIL_FROM_NAME.
attachments: Vec<Attachment>Files sent with the mail.
Implementations§
Source§impl Mail
impl Mail
Sourcepub fn new(
to: impl Into<String>,
subject: impl Into<String>,
text: impl Into<String>,
) -> Self
pub fn new( to: impl Into<String>, subject: impl Into<String>, text: impl Into<String>, ) -> Self
A mail to to with this subject and plain-text body.
Sourcepub fn html(self, html: impl Into<String>) -> Self
pub fn html(self, html: impl Into<String>) -> Self
Adds an HTML body; text is still sent as the plain alternative.
Sourcepub fn from(self, address: impl Into<String>) -> Self
pub fn from(self, address: impl Into<String>) -> Self
Sends as address instead of MAIL_FROM_ADDRESS / MAIL_FROM_NAME.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Mail
impl<'de> Deserialize<'de> for Mail
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Mail
Auto Trait Implementations§
impl Freeze for Mail
impl RefUnwindSafe for Mail
impl Send for Mail
impl Sync for Mail
impl Unpin for Mail
impl UnsafeUnpin for Mail
impl UnwindSafe for Mail
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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> ⓘ
Converts
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> ⓘ
Converts
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