email-message
Core email address and outbound message model primitives.
Scope contract
- This crate models outbound email content and addresses.
- RFC822/MIME wire parsing and rendering are provided by
email-message-wire. - Provider-specific limits and operational policies belong to transport crates.
Stability Contract
EmailAddressvalues are normalized viaaddr-specduring parsing.- Address display-name formatting may be canonicalized during render (
Display) and is not guaranteed byte-for-byte equivalent with source text. - Address/message parse-render roundtrips preserve semantic values (mailbox/group membership and header meaning), but not raw wire formatting details.
- Public enums marked
#[non_exhaustive]may gain variants in minor releases.
Feature Flags
serde: enablesSerialize/Deserializederives for public model types.schemars: enablesJsonSchemaderives for public model types.arbitrary: enablesarbitrary::Arbitraryderives to support fuzz/property generation.
std support
This crate currently requires std.
Why no no_std today?
- Parsing backends currently depend on
std. - The crate uses owned strings/collections and parser components that are not
no_std-ready.
MIME model
- Enable the
mimefeature to useBody::MimeandMimePart. - MIME parsing/rendering is provided by
email-message-wire.
Wire format support
- RFC822/MIME parsing and rendering are provided by
email-message-wire.
Metadata policy
- Put provider-agnostic message semantics in
Message. Examples:Date,Message-ID,Sender, recipients, body, attachments. - Put arbitrary outbound headers in
Message.headerswhen they should survive both SMTP and structured API paths. - Put provider-specific controls in transport crates via typed
TransportOptions, not in the message model. - Avoid adding fields to
Messageunless they have clear cross-provider meaning and stable semantics across structured and raw delivery.
Worker-friendly payloads
- With the
serdefeature enabled,Messageis a good serializable content payload inside a queued worker envelope such asemail_worker::EmailJob. AttachmentBody::Bytesis still the direct send/render form.AttachmentBody::Reference(AttachmentReference)is available for large attachments that should be dereferenced by a worker before transport delivery.- Reference resolution policy belongs outside this crate so the core model stays transport-agnostic.
Development
- Run tests:
cargo test -p email-message --all-features - Run clippy:
cargo clippy -p email-message --all-targets --all-features -- -D warnings - Run benches:
cargo bench -p email-message