internal/renderer/internet_message
This module implements functions to render a sendr message into the internet message format as specified in RFC 5322 and updated by RFC 6854.
Types
Errors that can occur when encoding header field bodies.
pub type FieldBodyError {
InvalidDate(#(timestamp.Timestamp, duration.Duration))
InvalidEmailAddress(String)
}
Constructors
-
InvalidDate(#(timestamp.Timestamp, duration.Duration))The date value is invalid.
-
InvalidEmailAddress(String)The email address is invalid.
Errors that can occur during message rendering.
pub type RenderError {
InvalidHeaderFieldName(String)
InvalidHeaderFieldBody(FieldBodyError)
InvalidEncoding(encoding.Encoding)
NoUsableEncodingFound(List(encoding.Encoding))
EncodingFailed(encoding.EncoderError)
}
Constructors
-
InvalidHeaderFieldName(String)The header field name is invalid (e.g., contains spaces or special characters).
-
InvalidHeaderFieldBody(FieldBodyError)The header field body is invalid and can’t be encoded.
-
InvalidEncoding(encoding.Encoding)An invalid encoding was specified for the context (header/body) it is used in.
-
NoUsableEncodingFound(List(encoding.Encoding))No suitable encoder could be found for the given input and constraints.
-
EncodingFailed(encoding.EncoderError)Encoding failed due to an encoder error.
Values
pub fn encode(
mail message: message.Message,
with mode: encoding.EncodingMode,
) -> Result(List(String), RenderError)
Render a sendr Message into an Internet Message format string.
This function converts a sendr/message.Message into a string
conforming to RFC 5322
and updated by RFC 6854.
The rendered message includes:
Dateheader (automatically generated from the current system time)From,Reply-To,To,Ccheaders (if set on the message)Subjectheader (if set on the message)Message-IDheader (generated from the sender’s address)MIME-Version: 1.0header- Message body (text and/or HTML) with appropriate MIME encoding
- Attachments (if any), wrapped in multipart/mixed or multipart/related