sendr/message

A simple message to be used with Mail Submission Agents. We do not adhere to specific RFC guidelines. E.g. Reply-To, Cc and Bcc are not able to utilize Group-addresses.

Types

A message with all essential fields.

pub type Message {
  Message(
    from: option.Option(mailbox.Mailbox),
    reply_to: option.Option(List(mailbox.Mailbox)),
    to: option.Option(List(mailbox.Mailbox)),
    cc: option.Option(List(mailbox.Mailbox)),
    bcc: option.Option(List(mailbox.Mailbox)),
    subject: option.Option(String),
    attachments: List(attachment.Attachment),
    body: body.Body,
  )
}

Constructors

Values

pub fn new() -> Message

Creates a fresh message that is empty.

pub fn set_attachments(
  of message: Message,
  to attachments: List(attachment.Attachment),
) -> Message

Set attachments on the message, replacing any existing attachments.

Attachments allow the sender to include additional files or data with the message. This function replaces the list of existing attachments in the message.

See: RFC 2045.

pub fn set_bcc(
  of message: Message,
  to mailboxes: List(mailbox.Mailbox),
) -> Message

(Blind Carbon Copy) Contains addresses of recipients of the message whose addresses are not to be revealed to other recipients of the message.

See: RFC 5322, section 3.6.3.

pub fn set_body(
  of message: Message,
  to body: body.Body,
) -> Message

Set the body of the message, replacing the existing body.

See: RFC 2045.

pub fn set_cc(
  of message: Message,
  to mailboxes: List(mailbox.Mailbox),
) -> Message

(Carbon Copy) Contains the addresses of others who are to receive the message, though the content of the message may not be directed at them.

See: RFC 5322, section 3.6.3.

pub fn set_from(
  of message: Message,
  to mailbox: mailbox.Mailbox,
) -> Message

Specifies the author(s) of the message, that is, the mailbox(es) of the person(s) or system(s) responsible for the writing of the message.

See: RFC 5322, section 3.6.2.

pub fn set_reply_to(
  of message: Message,
  to mailboxes: List(mailbox.Mailbox),
) -> Message

Indicates the mailbox(es) to which the author of the message suggests that replies be sent.

See: RFC 5322, section 3.6.2.

pub fn set_subject(
  of message: Message,
  to subject: String,
) -> Message

Sets the subject of the message.

The subject is a brief summary or title of the message content. It is typically displayed in the recipient’s mailbox and helps them understand the purpose or topic of the message.

See: RFC 5322, section 3.6.5.

pub fn set_to(
  of message: Message,
  to mailboxes: List(mailbox.Mailbox),
) -> Message

Contains the address(es) of the primary recipient(s) of the message.

See: RFC 5322, section 3.6.3.

Search Document