Struct lettre::message::MessageBuilder

source ·
pub struct MessageBuilder { /* private fields */ }
Available on crate feature builder only.
Expand description

A builder for messages

Implementations§

source§

impl MessageBuilder

source

pub fn new() -> Self

Creates a new default message builder

source

pub fn from(self, mbox: Mailbox) -> Self

Set or add mailbox to From header

Defined in RFC5322.

Shortcut for self.mailbox(header::From(mbox)).

source

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

Set Sender header. Should be used when providing several From mailboxes.

Defined in RFC5322.

Shortcut for self.header(header::Sender(mbox)).

source

pub fn date(self, st: SystemTime) -> Self

Add Date header to message

Shortcut for self.header(header::Date::new(st)).

source

pub fn date_now(self) -> Self

Set Date header using current date/time

Shortcut for self.date(SystemTime::now()), it is automatically inserted if no date has been provided.

source

pub fn reply_to(self, mbox: Mailbox) -> Self

Set or add mailbox to ReplyTo header

Defined in RFC5322.

Shortcut for self.mailbox(header::ReplyTo(mbox)).

source

pub fn to(self, mbox: Mailbox) -> Self

Set or add mailbox to To header

Shortcut for self.mailbox(header::To(mbox)).

source

pub fn cc(self, mbox: Mailbox) -> Self

Set or add mailbox to Cc header

Shortcut for self.mailbox(header::Cc(mbox)).

source

pub fn bcc(self, mbox: Mailbox) -> Self

Set or add mailbox to Bcc header

Shortcut for self.mailbox(header::Bcc(mbox)).

source

pub fn in_reply_to(self, id: String) -> Self

Set or add message id to In-Reply-To header

source

pub fn references(self, id: String) -> Self

Set or add message id to References header

source

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

Set Subject header to message

Shortcut for self.header(header::Subject(subject.into())).

source

pub fn message_id(self, id: Option<String>) -> Self

Set Message-ID header

Should generally be inserted by the mail relay.

If None is provided, an id will be generated in the <UUID@HOSTNAME>.

source

pub fn user_agent(self, id: String) -> Self

source

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

Set custom header to message

source

pub fn mailbox<H: Header + MailboxesHeader>(self, header: H) -> Self

Add mailbox to header

source

pub fn envelope(self, envelope: Envelope) -> Self

Force specific envelope (by default it is derived from headers)

source

pub fn keep_bcc(self) -> Self

Keep the Bcc header

By default, the Bcc header is removed from the email after using it to generate the message envelope. In some cases though, like when saving the email as an .eml, or sending through some transports (like the Gmail API) that don’t take a separate envelope value, it becomes necessary to keep the Bcc header.

Calling this method overrides the default behavior.

source

pub fn body<T: IntoBody>(self, body: T) -> Result<Message, EmailError>

Create Message using a Vec<u8>, String, or Body body

Automatically gets encoded with 7bit, quoted-printable or base64 Content-Transfer-Encoding, based on the most efficient and valid encoding for body.

source

pub fn multipart(self, part: MultiPart) -> Result<Message, EmailError>

Create message using mime body (MultiPart)

source

pub fn singlepart(self, part: SinglePart) -> Result<Message, EmailError>

Create message using mime body (SinglePart)

Trait Implementations§

source§

impl Clone for MessageBuilder

source§

fn clone(&self) -> MessageBuilder

Returns a copy 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 Default for MessageBuilder

source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> Chain<T> for T

source§

fn len(&self) -> usize

The number of items that this chain link consists of.
source§

fn append_to(self, v: &mut Vec<T>)

Append the elements in this link to the chain.
source§

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

§

type Iter = Once<T>

An iterator over the items within this container, by value.
source§

fn get_iter(&self) -> <T as Container<T>>::Iter

Iterate over the elements of the container (using internal iteration because GATs are unstable).
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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>,

§

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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

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