Rust

message

Module

RFC 5322 messages.

Contents

use utopia_smtp::Date;
Rust
pub struct Date

A point in time with the UTC offset it is written in, for the Date header.

use utopia_smtp::Message;
Rust
pub struct Message

An RFC 5322 message, with the MIME structure chosen from what was set: one text part, or multipart/alternative for text and HTML, inside multipart/related with inline attachments, inside multipart/mixed with the others.

Blind recipients are carried in the envelope (crate::Envelope::from_message), never written to a header.

Rust
use utopia_smtp::{Address, Date, Message};

let message = Message::builder(Address::new("jane@example.test", "Jane Doe")?, "Hello")
    .to(Address::new("john@example.test", "")?)
    .text("Body")
    .date(Date::new(1_786_613_400, 0))
    .message_id("fixed@example.test")
    .build()?;

let rendered = String::from_utf8(message.to_bytes()?).unwrap();
assert!(rendered.starts_with("Date: Thu, 13 Aug 2026 09:30:00 +0000\r\nFrom: \"Jane Doe\" <jane@example.test>\r\n"));
use utopia_smtp::MessageBuilder;
Rust
pub struct MessageBuilder

Collects what a Message carries; MessageBuilder::build checks it.