Skip to main content

Message

Struct Message 

Source
pub struct Message { /* private fields */ }
Expand description

One email, before it becomes bytes.

Implementations§

Source§

impl Message

Source

pub fn new() -> Message

Source

pub fn from(self, address: impl IntoAddress) -> Message

Source

pub fn to(self, address: impl IntoAddress) -> Message

Source

pub fn cc(self, address: impl IntoAddress) -> Message

Source

pub fn bcc(self, address: impl IntoAddress) -> Message

A blind copy. The address reaches the server in RCPT TO and appears in no header — that is the whole point, and getting it wrong discloses every recipient to every other one.

Source

pub fn reply_to(self, address: impl IntoAddress) -> Message

Source

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

Source

pub fn text(self, body: impl Into<String>) -> Message

Source

pub fn html(self, body: impl Into<String>) -> Message

Source

pub fn attach(self, attachment: Attachment) -> Message

Source

pub fn header( self, name: impl Into<String>, value: impl Into<String>, ) -> Message

Add a header of your own. X- headers, mostly.

Source

pub fn with_date(self, date: impl Into<String>) -> Message

Pin the Date header. Tests want a message that does not change between runs; nothing else should call this.

Source

pub fn with_message_id(self, id: impl Into<String>) -> Message

Pin the Message-ID, for the same reason as Message::with_date.

Source

pub fn with_boundary(self, boundary: impl Into<String>) -> Message

Pin the MIME boundary, for the same reason again.

Source

pub fn sender(&self) -> Option<&Address>

Source

pub fn subject_text(&self) -> &str

Source

pub fn text_body(&self) -> Option<&str>

The plain-text body, before any transfer encoding.

What the log transport prints. Quoted-printable is correct on the wire and useless on a terminal: it breaks any line over 76 columns with a soft =, which lands inside a long link and makes the URL somebody copies a different URL from the one that was sent.

Source

pub fn html_body(&self) -> Option<&str>

Source

pub fn attachments(&self) -> &[Attachment]

Source

pub fn to_addresses(&self) -> &[Address]

Source

pub fn recipients(&self) -> Vec<&Address>

Everyone the message is addressed to, headers included.

Source

pub fn envelope_recipients(&self) -> Vec<String>

The envelope: who the server is asked to deliver to, Bcc included.

Source

pub fn validate(&self) -> Result<()>

Everything that must be true before this can go anywhere.

Source

pub fn to_mime(&self) -> Result<String>

Render the whole message: headers, then the MIME body.

Source

pub fn to_smtp_data(&self) -> Result<String>

The message as the DATA phase wants it: dot-stuffed, CRLF throughout.

Trait Implementations§

Source§

impl Clone for Message

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Message

Source§

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

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

impl Default for Message

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> 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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.