#[non_exhaustive]pub struct MessageBuilder { /* private fields */ }Expand description
Builder for Message.
Implementations§
Source§impl MessageBuilder
impl MessageBuilder
Sourcepub fn from_mailbox(self, from: Mailbox) -> Self
pub fn from_mailbox(self, from: Mailbox) -> Self
Sets the From mailbox.
Named from_mailbox (rather than from) to avoid shadowing the
From::from trait method and the Message::from_mailbox accessor.
Sourcepub fn to<I>(self, to: I) -> Selfwhere
I: IntoIterator<Item = Address>,
pub fn to<I>(self, to: I) -> Selfwhere
I: IntoIterator<Item = Address>,
Replace the entire To recipient list. To append a single recipient,
use Self::add_to.
Sourcepub fn cc<I>(self, cc: I) -> Selfwhere
I: IntoIterator<Item = Address>,
pub fn cc<I>(self, cc: I) -> Selfwhere
I: IntoIterator<Item = Address>,
Replace the entire Cc recipient list. To append, use Self::add_cc.
Sourcepub fn bcc<I>(self, bcc: I) -> Selfwhere
I: IntoIterator<Item = Address>,
pub fn bcc<I>(self, bcc: I) -> Selfwhere
I: IntoIterator<Item = Address>,
Replace the entire Bcc recipient list. To append, use Self::add_bcc.
Sourcepub fn reply_to<I>(self, reply_to: I) -> Selfwhere
I: IntoIterator<Item = Address>,
pub fn reply_to<I>(self, reply_to: I) -> Selfwhere
I: IntoIterator<Item = Address>,
Replace the entire Reply-To list.
Sourcepub fn add_reply_to(self, reply_to: impl Into<Address>) -> Self
pub fn add_reply_to(self, reply_to: impl Into<Address>) -> Self
Append a recipient to the Reply-To list.
Sourcepub const fn date(self, date: OffsetDateTime) -> Self
pub const fn date(self, date: OffsetDateTime) -> Self
Sets the optional message date.
Sourcepub fn message_id(self, message_id: MessageId) -> Self
pub fn message_id(self, message_id: MessageId) -> Self
Sets the optional message id.
Sourcepub fn headers<I>(self, headers: I) -> Selfwhere
I: IntoIterator<Item = Header>,
pub fn headers<I>(self, headers: I) -> Selfwhere
I: IntoIterator<Item = Header>,
Replaces all custom headers.
Sourcepub fn add_header(self, header: Header) -> Self
pub fn add_header(self, header: Header) -> Self
Append a single custom header.
Sourcepub fn attachments<I>(self, attachments: I) -> Selfwhere
I: IntoIterator<Item = Attachment>,
pub fn attachments<I>(self, attachments: I) -> Selfwhere
I: IntoIterator<Item = Attachment>,
Replaces all attachments.
Sourcepub fn add_attachment(self, attachment: Attachment) -> Self
pub fn add_attachment(self, attachment: Attachment) -> Self
Append a single attachment.
Sourcepub fn build_unchecked(self) -> Message
pub fn build_unchecked(self) -> Message
Returns the underlying Message without running outbound
validation.
Reserved for paths that construct a Message from already-parsed
inbound data, for example email_message_wire::parse_rfc822,
where the wire-format invariants come from the parser and the
outbound rules (From set, at least one recipient, no reserved
header collisions, no CRLF in subject) are not meaningful.
Outbound callers should use Self::build or
Self::build_outbound instead. Wrapping the result of
build_unchecked in OutboundMessage::new re-runs the validation
you skipped, with no benefit.
Sourcepub fn build(self) -> Result<Message, MessageValidationError>
pub fn build(self) -> Result<Message, MessageValidationError>
Build and validate the message.
§Errors
Returns MessageValidationError when required message fields are
missing or inconsistent.
Sourcepub fn build_outbound(self) -> Result<OutboundMessage, MessageValidationError>
pub fn build_outbound(self) -> Result<OutboundMessage, MessageValidationError>
Build, validate, and wrap the message for outbound delivery.
§Errors
Returns MessageValidationError when required message fields are
missing or inconsistent.
Trait Implementations§
Source§impl Clone for MessageBuilder
impl Clone for MessageBuilder
Source§fn clone(&self) -> MessageBuilder
fn clone(&self) -> MessageBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more