pub struct Message { /* private fields */ }Expand description
One email, before it becomes bytes.
Implementations§
Source§impl Message
impl Message
pub fn new() -> Message
pub fn from(self, address: impl IntoAddress) -> Message
pub fn to(self, address: impl IntoAddress) -> Message
pub fn cc(self, address: impl IntoAddress) -> Message
Sourcepub fn bcc(self, address: impl IntoAddress) -> Message
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.
pub fn reply_to(self, address: impl IntoAddress) -> Message
pub fn subject(self, subject: impl Into<String>) -> Message
pub fn text(self, body: impl Into<String>) -> Message
pub fn html(self, body: impl Into<String>) -> Message
pub fn attach(self, attachment: Attachment) -> Message
Sourcepub fn header(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> Message
pub fn header( self, name: impl Into<String>, value: impl Into<String>, ) -> Message
Add a header of your own. X- headers, mostly.
Sourcepub fn with_date(self, date: impl Into<String>) -> Message
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.
Sourcepub fn with_message_id(self, id: impl Into<String>) -> Message
pub fn with_message_id(self, id: impl Into<String>) -> Message
Pin the Message-ID, for the same reason as Message::with_date.
Sourcepub fn with_boundary(self, boundary: impl Into<String>) -> Message
pub fn with_boundary(self, boundary: impl Into<String>) -> Message
Pin the MIME boundary, for the same reason again.
pub fn sender(&self) -> Option<&Address>
pub fn subject_text(&self) -> &str
Sourcepub fn text_body(&self) -> Option<&str>
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.
pub fn html_body(&self) -> Option<&str>
pub fn attachments(&self) -> &[Attachment]
pub fn to_addresses(&self) -> &[Address]
Sourcepub fn recipients(&self) -> Vec<&Address>
pub fn recipients(&self) -> Vec<&Address>
Everyone the message is addressed to, headers included.
Sourcepub fn envelope_recipients(&self) -> Vec<String>
pub fn envelope_recipients(&self) -> Vec<String>
The envelope: who the server is asked to deliver to, Bcc included.
Sourcepub fn to_smtp_data(&self) -> Result<String>
pub fn to_smtp_data(&self) -> Result<String>
The message as the DATA phase wants it: dot-stuffed, CRLF throughout.