#[non_exhaustive]pub struct Message {
pub to: String,
pub from: String,
pub reply_to: Option<String>,
pub subject: String,
pub html: String,
pub text: String,
pub idempotency_key: Option<String>,
pub tags: Vec<String>,
pub headers: Vec<(String, String)>,
}Expand description
An outbound mail. text is always sent alongside html.
#[non_exhaustive]: build one with Message::new and the builder
methods rather than a struct literal. A channel that has to set a
header — RFC 8058 one-click unsubscribe, say — should not be a
breaking change for every other caller, and before this it was.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.to: String§from: String§reply_to: Option<String>§subject: String§html: String§text: String§idempotency_key: Option<String>Passed through as an Idempotency-Key where the provider supports it.
headers: Vec<(String, String)>Extra RFC 5322 headers, in order.
For headers the shape of Message does not name and should not:
List-Unsubscribe and List-Unsubscribe-Post are the reason this
exists, because Gmail and Yahoo have required one-click
unsubscribe of bulk senders since 2024. An adapter that cannot
send custom headers must say so rather than drop them silently.
Implementations§
Source§impl Message
impl Message
Sourcepub fn new(
to: impl Into<String>,
from: impl Into<String>,
subject: impl Into<String>,
text: impl Into<String>,
html: impl Into<String>,
) -> Self
pub fn new( to: impl Into<String>, from: impl Into<String>, subject: impl Into<String>, text: impl Into<String>, html: impl Into<String>, ) -> Self
The five parts every mail has. Everything else is a builder method.
Sourcepub fn reply_to(self, address: impl Into<String>) -> Self
pub fn reply_to(self, address: impl Into<String>) -> Self
Where a reply goes, when it is not from.
Sourcepub fn idempotency_key(self, key: impl Into<String>) -> Self
pub fn idempotency_key(self, key: impl Into<String>) -> Self
The key a provider that supports it uses to collapse a retry.
Labels for the provider’s own reporting.