Skip to main content

MessageBuilder

Struct MessageBuilder 

Source
#[non_exhaustive]
pub struct MessageBuilder { /* private fields */ }
Expand description

Builder for Message.

Implementations§

Source§

impl MessageBuilder

Source

pub const fn new(body: Body) -> Self

Source

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.

Source

pub fn sender(self, sender: Mailbox) -> Self

Source

pub fn to<I>(self, to: I) -> Self
where I: IntoIterator<Item = Address>,

Replace the entire To recipient list. To append a single recipient, use Self::add_to.

Source

pub fn add_to(self, to: impl Into<Address>) -> Self

Append a recipient to the To list.

Source

pub fn cc<I>(self, cc: I) -> Self
where I: IntoIterator<Item = Address>,

Replace the entire Cc recipient list. To append, use Self::add_cc.

Source

pub fn add_cc(self, cc: impl Into<Address>) -> Self

Append a recipient to the Cc list.

Source

pub fn bcc<I>(self, bcc: I) -> Self
where I: IntoIterator<Item = Address>,

Replace the entire Bcc recipient list. To append, use Self::add_bcc.

Source

pub fn add_bcc(self, bcc: impl Into<Address>) -> Self

Append a recipient to the Bcc list.

Source

pub fn reply_to<I>(self, reply_to: I) -> Self
where I: IntoIterator<Item = Address>,

Replace the entire Reply-To list.

Source

pub fn add_reply_to(self, reply_to: impl Into<Address>) -> Self

Append a recipient to the Reply-To list.

Source

pub fn subject(self, subject: impl Into<String>) -> Self

Source

pub const fn date(self, date: OffsetDateTime) -> Self

Source

pub fn message_id(self, message_id: MessageId) -> Self

Source

pub fn headers<I>(self, headers: I) -> Self
where I: IntoIterator<Item = Header>,

Source

pub fn add_header(self, header: Header) -> Self

Append a single custom header.

Source

pub fn attachments<I>(self, attachments: I) -> Self
where I: IntoIterator<Item = Attachment>,

Source

pub fn add_attachment(self, attachment: Attachment) -> Self

Append a single attachment.

Source

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.

Source

pub fn build(self) -> Result<Message, MessageValidationError>

Build and validate the message.

§Errors

Returns MessageValidationError when required message fields are missing or inconsistent.

Source

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

Source§

fn clone(&self) -> MessageBuilder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MessageBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for MessageBuilder

Source§

fn eq(&self, other: &MessageBuilder) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for MessageBuilder

Source§

impl StructuralPartialEq for MessageBuilder

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.