correio/message
Immutable message construction. Delivery admission applies resource limits.
Types
pub opaque type Attachment
pub type AttachmentView {
AttachmentView(
filename: String,
content_type: String,
bytes: BitArray,
disposition: Disposition,
)
}
Constructors
-
AttachmentView( filename: String, content_type: String, bytes: BitArray, disposition: Disposition, )
pub type Body {
Text(String)
Html(String)
Alternative(text: String, html: String)
}
Constructors
-
Text(String) -
Html(String) -
Alternative(text: String, html: String)
pub type Disposition {
AttachmentFile
Inline(content_id: String)
}
Constructors
-
AttachmentFile -
Inline(content_id: String)
pub type MessageError {
InvalidSubject
EmptyBody
InvalidHeader
ReservedHeader
InvalidAttachment
InvalidLimits
TooManyRecipients
TooManyHeaders
HeaderTooLarge
BodyTooLarge
AttachmentTooLarge
SubmissionTooLarge
EncodingFailed
}
Constructors
-
InvalidSubject -
EmptyBody -
InvalidHeader -
ReservedHeader -
InvalidAttachment -
InvalidLimits -
TooManyRecipients -
TooManyHeaders -
HeaderTooLarge -
BodyTooLarge -
AttachmentTooLarge -
SubmissionTooLarge -
EncodingFailed
A read-only projection. Constructing a View cannot construct a Message.
pub type View {
View(
from: address.Address,
to: List(address.Address),
cc: List(address.Address),
bcc: List(address.Address),
subject: String,
body: Body,
reply_to: option.Option(address.Address),
envelope_sender: address.Address,
headers: List(#(String, String)),
attachments: List(Attachment),
)
}
Constructors
-
View( from: address.Address, to: List(address.Address), cc: List(address.Address), bcc: List(address.Address), subject: String, body: Body, reply_to: option.Option(address.Address), envelope_sender: address.Address, headers: List(#(String, String)), attachments: List(Attachment), )
Values
pub fn add_bcc(
message: Message,
address: address.Address,
) -> Message
pub fn add_cc(
message: Message,
address: address.Address,
) -> Message
pub fn add_to(
message: Message,
address: address.Address,
) -> Message
pub fn attach(
message: Message,
attachment: Attachment,
) -> Message
pub fn attachment(
filename: String,
content_type: String,
bytes: BitArray,
disposition: Disposition,
) -> Result(Attachment, MessageError)
pub fn attachment_view(attachment: Attachment) -> AttachmentView
pub fn default_limits() -> Limits
Defaults: 100 recipients, 50 custom headers, 8 KiB header values, 1 MiB body content, 10 MiB per attachment and 25 MiB encoded submission.
pub fn envelope(
message: Message,
) -> #(address.Address, List(address.Address))
pub fn header(
message: Message,
name: String,
value: String,
) -> Result(Message, MessageError)
Custom field bodies preserve structured ASCII syntax. Unicode custom field bodies and physical lines longer than 998 bytes are refused. Unicode subject and display-name encoding remains available through their dedicated APIs.
pub fn limits(
recipients: Int,
headers: Int,
header_bytes: Int,
body_bytes: Int,
attachment_bytes: Int,
submission_bytes: Int,
) -> Result(Limits, MessageError)
pub fn maximum_submission_bytes(limits: Limits) -> Int
pub fn new(
from from: address.Address,
to to: address.Address,
subject subject: String,
body body: Body,
) -> Result(Message, MessageError)
pub fn set_envelope_sender(
message: Message,
address: address.Address,
) -> Message
pub fn set_reply_to(
message: Message,
address: address.Address,
) -> Message
pub fn validate(
message: Message,
limits: Limits,
) -> Result(Nil, MessageError)