Skip to main content

EmailMessage

Struct EmailMessage 

Source
pub struct EmailMessage {
    pub message_id: String,
    pub from: String,
    pub to: String,
    pub client_ip: Option<IpAddr>,
    pub helo_domain: Option<String>,
    /* private fields */
}
Expand description

Represents an email message for storage operations.

Headers are stored as an ordered Vec (preserving RFC 5322 order and supporting duplicate headers such as Received). A cached raw field holds the full serialized form; call rebuild after modifying headers so that raw reflects the changes.

Fields§

§message_id: String

Unique message identifier, RFC 5322 message-id format.

§from: String

Sender address, RFC 5322 address format.

§to: String

Recipient address, RFC 5322 address format.

§client_ip: Option<IpAddr>

IP address of the connecting SMTP client (for SPF verification).

§helo_domain: Option<String>

HELO/EHLO domain presented by the connecting client (for SPF verification).

Implementations§

Source§

impl EmailMessage

Source

pub fn new(from: String, to: String, raw: String) -> Self

Source

pub fn from_raw(from: &str, to: &str, raw: &str) -> Self

Source

pub fn with_id( message_id: String, from: String, to: String, subject: String, raw: String, ) -> Self

Source

pub fn header(&self, name: &str) -> Option<&str>

Returns the first header value matching name (case-insensitive).

Source

pub fn subject(&self) -> &str

Returns the email subject (convenience for header("Subject")).

Source

pub fn raw(&self) -> &str

Returns the full serialized email (headers + blank line + content).

Returns the cached Self::raw field. Call rebuild after modifying headers to ensure this is up to date.

Source

pub fn original_raw(&self) -> &str

Returns the original raw email as received, before any transformer modifications.

Use this for byte-exact operations such as DKIM signature verification, where the original byte sequence must be preserved.

Source

pub fn body(&self) -> &str

Returns the message body after the header section (RFC 5322 body).

Source

pub fn has_headers(&self) -> bool

Returns whether the message has any MIME headers.

Source

pub fn headers(&self) -> &[(String, String)]

Returns a reference to the ordered header list.

Source

pub fn prepend_header(&mut self, name: &str, value: &str)

Prepends a header to the beginning of the header list.

The cached raw field is not updated automatically, call rebuild once after all header modifications are done (e.g. after running all transformers via [MessageTransformer::apply]).

Source

pub fn rebuild(&mut self)

Rebuilds the cached raw field from headers and body.

Call this once after all header modifications are complete so that raw() returns the up-to-date serialized form.

Pre-computes the exact byte length, allocates once, and writes all parts via push_str.

Trait Implementations§

Source§

impl Clone for EmailMessage

Source§

fn clone(&self) -> EmailMessage

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EmailMessage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more