pub struct Message {
pub from: Address,
pub to: Vec<Address>,
pub cc: Vec<Address>,
pub bcc: Vec<Address>,
pub reply_to: Vec<Address>,
pub return_path: Option<String>,
pub subject: String,
pub text: Option<String>,
pub html: Option<String>,
pub attachments: Vec<Attachment>,
pub headers: Vec<(String, String)>,
}Expand description
A message to send. Pre-rendered: callers supply finished bodies.
At least one of text or html MUST be Some — a backend that
receives a message with both bodies empty returns
MailerError::InvalidMessage without attempting a send.
Fields§
§from: AddressSender. Used for both the From: header and the SMTP
envelope sender. To separate them (DSN routing, bounce
handling) set return_path.
to: Vec<Address>Primary recipients. MUST be non-empty.
cc: Vec<Address>Carbon-copy recipients. May be empty.
bcc: Vec<Address>Blind carbon-copy recipients. May be empty.
reply_to: Vec<Address>Reply-to addresses. Empty means “use from”.
return_path: Option<String>Optional envelope sender (SMTP MAIL FROM / SES Return-Path).
None means the backend should reuse from.email.
subject: StringSubject line. UTF-8; backends handle MIME-encoding if needed.
text: Option<String>Plain-text body. Either this or html (or both) MUST be set.
html: Option<String>HTML body. Either this or text (or both) MUST be set.
attachments: Vec<Attachment>File attachments. May be empty.
headers: Vec<(String, String)>Extra headers. Use for standards-defined headers like
List-Unsubscribe, List-Unsubscribe-Post,
In-Reply-To, References. Keys are case-insensitive.
Backends MAY reject (MailerError::InvalidMessage) headers
they explicitly forbid (e.g., Bcc, Date, Message-ID
when they assign them themselves).