Expand description
Typed email addresses, message content, and validated outbound messages.
Use this crate to construct provider-independent email values. RFC 822/MIME
byte parsing and rendering are intentionally handled by
email-message-wire, while transport crates apply provider-specific limits
and delivery policies.
§Quick start
use email_message::{Address, Body, Message};
let message = Message::builder(Body::text("Hello"))
.from_mailbox("sender@example.com".parse()?)
.to(vec![Address::Mailbox("recipient@example.com".parse()?)])
.subject("Welcome")
.build_outbound()?;
assert_eq!(message.as_message().subject(), Some("Welcome"));§Cargo features
No features are enabled by default.
mimeexposesMimePart, the low-level MIME tree. The other MIME value types are always available. Theemail-message-wirecrate enables this feature on its dependency because rendering needs the tree.serdeimplements serialization and deserialization for public model types. Binary attachment and MIME bodies use padded base64 strings.schemarsimplements JSON Schema generation. When combined withmime, schemas includeMimePart.arbitraryimplementsarbitrary::Arbitraryfor generated test data, including feature-gated model types that are also enabled.rfc5322-string-compatletsserdedeserializers andschemarsschemas accept RFC 5322 address strings in addition to the typed object shape. It has no effect unlessserdeorschemarsis also enabled.
All features are additive and may be enabled together.
§Platform support
This is a std crate with no operating-system APIs or target-specific
implementation. It supports Rust targets that provide the standard library.
Re-exports§
pub use address::Address;pub use address::AddressBackendError;pub use address::AddressList;pub use address::AddressParseError;pub use address::Group;pub use address::GroupParseError;pub use address::MAX_ADDRESS_INPUT_BYTES;pub use address::Mailbox;pub use address::MailboxList;pub use address::MailboxParseError;pub use email::EmailAddress;pub use email::EmailAddressParseError;pub use message::Attachment;pub use message::AttachmentBody;pub use message::AttachmentReference;pub use message::Body;pub use message::Disposition;pub use message::Envelope;pub use message::Header;pub use message::HeaderValidationError;pub use message::Message;pub use message::MessageBuilder;pub use message::MessageValidationError;pub use message::OutboundMessage;pub use message_id::MessageId;pub use message_id::MessageIdParseError;pub use mime_types::ContentDisposition;pub use mime_types::ContentDispositionParseError;pub use mime_types::ContentTransferEncoding;pub use mime_types::ContentTransferEncodingParseError;pub use mime_types::ContentType;pub use mime_types::ContentTypeParseError;pub use mime_types::MediaType;pub use mime_types::ParameterValue;pub use mime_types::MimePart;
Modules§
- address
- RFC 5322 mailboxes, groups, addresses, and address lists. RFC 5322 mailbox, group, address, and address-list values.
- Validated RFC 5322
addr-specemail addresses. Validated RFC 5322addr-specemail addresses. - message
- Message bodies, attachments, headers, builders, and outbound validation. Provider-independent message bodies, attachments, headers, and validation.
- message_
id - Validated RFC 5322
Message-IDvalues. Validated RFC 5322Message-IDvalues. - mime_
types - MIME content-type, content-disposition, and content-transfer-encoding types.
Enums§
- Parse
Error - Error returned when parsing one of the crate’s core string value types.