Struct mail_builder::MessageBuilder
source · pub struct MessageBuilder<'x> {
pub headers: Vec<(Cow<'x, str>, HeaderType<'x>)>,
pub html_body: Option<MimePart<'x>>,
pub text_body: Option<MimePart<'x>>,
pub attachments: Option<Vec<MimePart<'x>>>,
pub body: Option<MimePart<'x>>,
}
Expand description
Builds an RFC5322 compliant MIME email message.
Fields§
§headers: Vec<(Cow<'x, str>, HeaderType<'x>)>
§html_body: Option<MimePart<'x>>
§text_body: Option<MimePart<'x>>
§attachments: Option<Vec<MimePart<'x>>>
§body: Option<MimePart<'x>>
Implementations§
source§impl<'x> MessageBuilder<'x>
impl<'x> MessageBuilder<'x>
sourcepub fn message_id(self, value: impl Into<MessageId<'x>>) -> Self
pub fn message_id(self, value: impl Into<MessageId<'x>>) -> Self
Set the Message-ID header. If no Message-ID header is set, one will be generated automatically.
sourcepub fn in_reply_to(self, value: impl Into<MessageId<'x>>) -> Self
pub fn in_reply_to(self, value: impl Into<MessageId<'x>>) -> Self
Set the In-Reply-To header.
sourcepub fn references(self, value: impl Into<MessageId<'x>>) -> Self
pub fn references(self, value: impl Into<MessageId<'x>>) -> Self
Set the References header.
sourcepub fn date(self, value: impl Into<Date>) -> Self
pub fn date(self, value: impl Into<Date>) -> Self
Set the Date header. If no Date header is set, one will be generated automatically.
sourcepub fn header(
self,
header: impl Into<Cow<'x, str>>,
value: impl Into<HeaderType<'x>>
) -> Self
pub fn header( self, header: impl Into<Cow<'x, str>>, value: impl Into<HeaderType<'x>> ) -> Self
Add a custom header.
sourcepub fn headers<T, U, V>(self, header: T, values: U) -> Selfwhere
T: Into<Cow<'x, str>>,
U: IntoIterator<Item = V>,
V: Into<HeaderType<'x>>,
pub fn headers<T, U, V>(self, header: T, values: U) -> Selfwhere T: Into<Cow<'x, str>>, U: IntoIterator<Item = V>, V: Into<HeaderType<'x>>,
Set custom headers.
sourcepub fn text_body(self, value: impl Into<Cow<'x, str>>) -> Self
pub fn text_body(self, value: impl Into<Cow<'x, str>>) -> Self
Set the plain text body of the message. Note that only one plain text body
per message can be set using this function.
To build more complex MIME body structures, use the body
method instead.
sourcepub fn html_body(self, value: impl Into<Cow<'x, str>>) -> Self
pub fn html_body(self, value: impl Into<Cow<'x, str>>) -> Self
Set the HTML body of the message. Note that only one HTML body
per message can be set using this function.
To build more complex MIME body structures, use the body
method instead.
sourcepub fn attachment(
self,
content_type: impl Into<ContentType<'x>>,
filename: impl Into<Cow<'x, str>>,
value: impl Into<BodyPart<'x>>
) -> Self
pub fn attachment( self, content_type: impl Into<ContentType<'x>>, filename: impl Into<Cow<'x, str>>, value: impl Into<BodyPart<'x>> ) -> Self
Add a binary attachment to the message.
sourcepub fn inline(
self,
content_type: impl Into<ContentType<'x>>,
cid: impl Into<Cow<'x, str>>,
value: impl Into<BodyPart<'x>>
) -> Self
pub fn inline( self, content_type: impl Into<ContentType<'x>>, cid: impl Into<Cow<'x, str>>, value: impl Into<BodyPart<'x>> ) -> Self
Add an inline binary to the message.
sourcepub fn write_body(self, output: impl Write) -> Result<()>
pub fn write_body(self, output: impl Write) -> Result<()>
Write the message body without headers.
sourcepub fn write_to_vec(self) -> Result<Vec<u8>>
pub fn write_to_vec(self) -> Result<Vec<u8>>
Build message to a Vec
sourcepub fn write_to_string(self) -> Result<String>
pub fn write_to_string(self) -> Result<String>
Build message to a String.
Trait Implementations§
source§impl<'x> Clone for MessageBuilder<'x>
impl<'x> Clone for MessageBuilder<'x>
source§fn clone(&self) -> MessageBuilder<'x>
fn clone(&self) -> MessageBuilder<'x>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more