March Docs

Marathon.Email

The email value + a Swoosh-style pure builder pipeline (specs/email.md §3). Provider-agnostic; part of the mail core intended for extraction into a library.

Email.new()
  |> Email.from({name: "forgepm.org", address: "[email protected]"})
  |> Email.to({name: "", address: "[email protected]"})
  |> Email.subject("Confirm your account")
  |> Email.text_body("...")

Types

typeEmailEmail = {#

Functions

fnbccbcc(email : Email, addr : { name: String, address: String }) : Email do { email with bcc: List.append(email.bcc, [clean_addr(addr)]) } end#

Append a Bcc recipient.

fncccc(email : Email, addr : { name: String, address: String }) : Email do { email with cc: List.append(email.cc, [clean_addr(addr)]) } end#

Append a Cc recipient.

fnfromfrom(email : Email, addr : { name: String, address: String }) : Email do { email with from: clean_addr(addr) } end#

Set the sender.

fnheaderheader(email : Email, name : String, value : String) : Email#

Add a raw header (name, value). CR/LF are stripped from both.

fnhtml_bodyhtml_body(email : Email, body : String) : Email do { email with html_body: body } end#

Set the HTML body.

fnnewnew() : Email#

An empty email: blank from, empty recipient lists and bodies, no reply_to. Fill via the builders.

fnreply_toreply_to(email : Email, addr : { name: String, address: String }) : Email do { email with reply_to: Some(clean_addr(addr)) } end#

Set the Reply-To address.

fnsubjectsubject(email : Email, s : String) : Email do { email with subject: Marathon.Address.strip_crlf(s) } end#

Set the subject. CR/LF are stripped (header-injection guard, specs/email.md §7).

fntext_bodytext_body(email : Email, body : String) : Email do { email with text_body: body } end#

Set the plain-text body.

fntoto(email : Email, addr : { name: String, address: String }) : Email do { email with to: List.append(email.to, [clean_addr(addr)]) } end#

Append a To recipient (order preserved).