pub struct Email {Show 13 fields
pub from: Option<Address>,
pub to: Vec<Address>,
pub cc: Vec<Address>,
pub bcc: Vec<Address>,
pub reply_to: Vec<Address>,
pub subject: String,
pub text_body: Option<String>,
pub html_body: Option<String>,
pub attachments: Vec<Attachment>,
pub headers: HashMap<String, String>,
pub assigns: HashMap<String, Value>,
pub private: HashMap<String, Value>,
pub provider_options: HashMap<String, Value>,
}Expand description
An email message.
Use the builder pattern to construct emails:
use missive::Email;
let email = Email::new()
.from("sender@example.com")
.to("recipient@example.com")
.subject("Hello!")
.text_body("Plain text content")
.html_body("<h1>HTML content</h1>");§Fields
from,to,cc,bcc- Addressesreply_to- Reply-to addresses (supports multiple)subject,text_body,html_body- Contentattachments- File attachmentsheaders- Custom email headersassigns- Template variables (for use with templating systems)private- Private storage for libraries/frameworksprovider_options- Provider-specific options (tags, templates, etc.)
Fields§
§from: Option<Address>Sender address
to: Vec<Address>Primary recipients
cc: Vec<Address>Carbon copy recipients
bcc: Vec<Address>Blind carbon copy recipients
reply_to: Vec<Address>Reply-to addresses (supports multiple)
subject: StringEmail subject line
text_body: Option<String>Plain text body
html_body: Option<String>HTML body
attachments: Vec<Attachment>File attachments
headers: HashMap<String, String>Custom email headers
assigns: HashMap<String, Value>Template variables for use with templating systems.
private: HashMap<String, Value>Private storage for libraries/frameworks (e.g., template paths, metadata).
provider_options: HashMap<String, Value>Provider-specific options (e.g., tracking, tags, templates)
Implementations§
Source§impl Email
impl Email
Sourcepub fn from(self, addr: impl ToAddress) -> Self
pub fn from(self, addr: impl ToAddress) -> Self
Set the sender address.
Accepts anything that implements ToAddress:
"email@example.com"- just email("Name", "email@example.com")- name and email- Custom types that implement
ToAddress
Sourcepub fn to(self, addr: impl ToAddress) -> Self
pub fn to(self, addr: impl ToAddress) -> Self
Add a recipient.
Can be called multiple times to add multiple recipients.
Accepts anything that implements ToAddress.
Sourcepub fn cc(self, addr: impl ToAddress) -> Self
pub fn cc(self, addr: impl ToAddress) -> Self
Add a CC recipient.
Accepts anything that implements ToAddress.
Sourcepub fn bcc(self, addr: impl ToAddress) -> Self
pub fn bcc(self, addr: impl ToAddress) -> Self
Add a BCC recipient.
Accepts anything that implements ToAddress.
Sourcepub fn reply_to(self, addr: impl ToAddress) -> Self
pub fn reply_to(self, addr: impl ToAddress) -> Self
Add a reply-to address.
Can be called multiple times to add multiple reply-to addresses.
Accepts anything that implements ToAddress.
Sourcepub fn put_reply_to(self, addrs: Vec<Address>) -> Self
pub fn put_reply_to(self, addrs: Vec<Address>) -> Self
Replace all reply-to addresses.
Sourcepub fn attachment(self, attachment: Attachment) -> Self
pub fn attachment(self, attachment: Attachment) -> Self
Add an attachment.
Sourcepub fn header(self, name: impl Into<String>, value: impl Into<String>) -> Self
pub fn header(self, name: impl Into<String>, value: impl Into<String>) -> Self
Add a custom header.
Sourcepub fn all_recipients(&self) -> Vec<&Address>
pub fn all_recipients(&self) -> Vec<&Address>
Get all recipients (to + cc + bcc).
Sourcepub fn has_attachments(&self) -> bool
pub fn has_attachments(&self) -> bool
Check if the email has any attachments.
Sourcepub fn inline_attachments(&self) -> Vec<&Attachment>
pub fn inline_attachments(&self) -> Vec<&Attachment>
Get inline attachments only.
Sourcepub fn regular_attachments(&self) -> Vec<&Attachment>
pub fn regular_attachments(&self) -> Vec<&Attachment>
Get regular (non-inline) attachments only.