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 new() -> MessageBuilder<'x>
pub fn new() -> MessageBuilder<'x>
Create a new MessageBuilder.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub fn headers<T, U, V>(self, header: T, values: U) -> MessageBuilder<'x>
pub fn headers<T, U, V>(self, header: T, values: U) -> MessageBuilder<'x>
Set custom headers.
Sourcepub 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.
Sourcepub 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.
Sourcepub fn attachment(
self,
content_type: impl Into<ContentType<'x>>,
filename: impl Into<Cow<'x, str>>,
value: impl Into<BodyPart<'x>>,
) -> MessageBuilder<'x>
pub fn attachment( self, content_type: impl Into<ContentType<'x>>, filename: impl Into<Cow<'x, str>>, value: impl Into<BodyPart<'x>>, ) -> MessageBuilder<'x>
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>>,
) -> MessageBuilder<'x>
pub fn inline( self, content_type: impl Into<ContentType<'x>>, cid: impl Into<Cow<'x, str>>, value: impl Into<BodyPart<'x>>, ) -> MessageBuilder<'x>
Add an inline binary to the message.
Sourcepub fn body(self, value: MimePart<'x>) -> MessageBuilder<'x>
pub fn body(self, value: MimePart<'x>) -> MessageBuilder<'x>
Set a custom MIME body structure.
Sourcepub 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.
Sourcepub fn write_to_string(self) -> Result<String, Error>
pub fn write_to_string(self) -> Result<String, Error>
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