Struct async_mailer::MessageBuilder
pub struct MessageBuilder<'x> {
pub headers: Vec<(Cow<'x, str>, HeaderType<'x>), Global>,
pub html_body: Option<MimePart<'x>>,
pub text_body: Option<MimePart<'x>>,
pub attachments: Option<Vec<MimePart<'x>, Global>>,
pub body: Option<MimePart<'x>>,
}Expand description
Builds an RFC5322 compliant MIME email message.
Fields§
§headers: Vec<(Cow<'x, str>, HeaderType<'x>), Global>§html_body: Option<MimePart<'x>>§text_body: Option<MimePart<'x>>§attachments: Option<Vec<MimePart<'x>, Global>>§body: Option<MimePart<'x>>Implementations§
§impl<'x> MessageBuilder<'x>
impl<'x> MessageBuilder<'x>
pub fn new() -> MessageBuilder<'x>
pub fn new() -> MessageBuilder<'x>
Create a new MessageBuilder.
pub fn message_id(self, value: impl Into<MessageId<'x>>) -> MessageBuilder<'x>
pub fn message_id(self, value: impl Into<MessageId<'x>>) -> MessageBuilder<'x>
Set the Message-ID header. If no Message-ID header is set, one will be generated automatically.
pub fn in_reply_to(self, value: impl Into<MessageId<'x>>) -> MessageBuilder<'x>
pub fn in_reply_to(self, value: impl Into<MessageId<'x>>) -> MessageBuilder<'x>
Set the In-Reply-To header.
pub fn references(self, value: impl Into<MessageId<'x>>) -> MessageBuilder<'x>
pub fn references(self, value: impl Into<MessageId<'x>>) -> MessageBuilder<'x>
Set the References header.
pub fn sender(self, value: impl Into<Address<'x>>) -> MessageBuilder<'x>
pub fn sender(self, value: impl Into<Address<'x>>) -> MessageBuilder<'x>
Set the Sender header.
pub fn from(self, value: impl Into<Address<'x>>) -> MessageBuilder<'x>
pub fn from(self, value: impl Into<Address<'x>>) -> MessageBuilder<'x>
Set the From header.
pub fn to(self, value: impl Into<Address<'x>>) -> MessageBuilder<'x>
pub fn to(self, value: impl Into<Address<'x>>) -> MessageBuilder<'x>
Set the To header.
pub fn cc(self, value: impl Into<Address<'x>>) -> MessageBuilder<'x>
pub fn cc(self, value: impl Into<Address<'x>>) -> MessageBuilder<'x>
Set the Cc header.
pub fn bcc(self, value: impl Into<Address<'x>>) -> MessageBuilder<'x>
pub fn bcc(self, value: impl Into<Address<'x>>) -> MessageBuilder<'x>
Set the Bcc header.
pub fn reply_to(self, value: impl Into<Address<'x>>) -> MessageBuilder<'x>
pub fn reply_to(self, value: impl Into<Address<'x>>) -> MessageBuilder<'x>
Set the Reply-To header.
pub fn subject(self, value: impl Into<Text<'x>>) -> MessageBuilder<'x>
pub fn subject(self, value: impl Into<Text<'x>>) -> MessageBuilder<'x>
Set the Subject header.
pub fn date(self, value: impl Into<Date>) -> MessageBuilder<'x>
pub fn date(self, value: impl Into<Date>) -> MessageBuilder<'x>
Set the Date header. If no Date header is set, one will be generated automatically.
pub fn header(
self,
header: impl Into<Cow<'x, str>>,
value: impl Into<HeaderType<'x>>
) -> MessageBuilder<'x>
pub fn header( self, header: impl Into<Cow<'x, str>>, value: impl Into<HeaderType<'x>> ) -> MessageBuilder<'x>
Add a custom header.
pub fn headers<T, U, V>(self, header: T, values: U) -> MessageBuilder<'x>where
T: Into<Cow<'x, str>>,
U: IntoIterator<Item = V>,
V: Into<HeaderType<'x>>,
pub fn headers<T, U, V>(self, header: T, values: U) -> MessageBuilder<'x>where T: Into<Cow<'x, str>>, U: IntoIterator<Item = V>, V: Into<HeaderType<'x>>,
Set custom headers.
pub fn text_body(self, value: impl Into<Cow<'x, str>>) -> MessageBuilder<'x>
pub fn text_body(self, value: impl Into<Cow<'x, str>>) -> MessageBuilder<'x>
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.
pub fn html_body(self, value: impl Into<Cow<'x, str>>) -> MessageBuilder<'x>
pub fn html_body(self, value: impl Into<Cow<'x, str>>) -> MessageBuilder<'x>
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.
pub fn binary_attachment(
self,
content_type: impl Into<Cow<'x, str>>,
filename: impl Into<Cow<'x, str>>,
value: impl Into<Cow<'x, [u8]>>
) -> MessageBuilder<'x>
pub fn binary_attachment( self, content_type: impl Into<Cow<'x, str>>, filename: impl Into<Cow<'x, str>>, value: impl Into<Cow<'x, [u8]>> ) -> MessageBuilder<'x>
Add a binary attachment to the message.
pub fn text_attachment(
self,
content_type: impl Into<Cow<'x, str>>,
filename: impl Into<Cow<'x, str>>,
value: impl Into<Cow<'x, str>>
) -> MessageBuilder<'x>
pub fn text_attachment( self, content_type: impl Into<Cow<'x, str>>, filename: impl Into<Cow<'x, str>>, value: impl Into<Cow<'x, str>> ) -> MessageBuilder<'x>
Add a text attachment to the message.
pub fn binary_inline(
self,
content_type: impl Into<Cow<'x, str>>,
cid: impl Into<Cow<'x, str>>,
value: impl Into<Cow<'x, [u8]>>
) -> MessageBuilder<'x>
pub fn binary_inline( self, content_type: impl Into<Cow<'x, str>>, cid: impl Into<Cow<'x, str>>, value: impl Into<Cow<'x, [u8]>> ) -> MessageBuilder<'x>
Add an inline binary to the message.
pub fn body(self, value: MimePart<'x>) -> MessageBuilder<'x>
pub fn body(self, value: MimePart<'x>) -> MessageBuilder<'x>
Set a custom MIME body structure.
pub fn write_body(self, output: impl Write) -> Result<(), Error>
pub fn write_body(self, output: impl Write) -> Result<(), Error>
Write the message body without headers.
pub fn write_to_string(self) -> Result<String, Error>
pub fn write_to_string(self) -> Result<String, Error>
Build message to a String.
Trait Implementations§
§impl<'x> Clone for MessageBuilder<'x>
impl<'x> Clone for MessageBuilder<'x>
§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