Manuscript Documentation
v2026.12.0

@std/net/mail.ms#

Import each required symbol with import Name from "@std/net/mail.ms".

Address Type#

A mailbox: optional display name and the local@domain address.

Manuscript
type Address {
    address String
    name String = ""
}

Address.address#

The local@domain address without angle brackets.

Manuscript
address String

Address.name#

Display name with quotes removed; empty when none was given.

Manuscript
name String = ""

Address.to_string#

Formats as Name <addr>, quoting the name when it contains special characters, or as the bare address when there is no name.

Manuscript
fn to_string() String

Message Type#

A parsed message: header fields and the body after the first blank line.

Manuscript
type Message {
    headers Headers
    body String
}

Message.body#

Body text exactly as written after the blank line, with line endings kept.

Manuscript
body String

Message.headers#

Header block with folded lines joined.

Manuscript
headers Headers

decode_words Function#

Decodes RFC 2047 encoded words (=?utf-8?B?...?= and =?utf-8?Q?...?=) in header text. Only UTF-8, US-ASCII and ISO-8859-1 charsets are decoded; any other word is left as written.

Manuscript
fn decode_words(text String) String { ... }

parse_address Function#

Parses one mailbox: addr, <addr>, Name <addr> or "Quoted, Name" <addr>. Encoded words in the name are decoded. Comments are not supported. Text that is not a valid mailbox returns EBADMSG.

Manuscript
fn parse_address(text String) Result[Address, Error] { ... }

parse_address_list Function#

Parses a comma-separated address list, honoring quoted names and angle brackets. Empty items (a trailing comma) are skipped, and empty text gives an empty list. An invalid item returns EBADMSG.

Manuscript
fn parse_address_list(text String) Result[List[Address], Error] { ... }

parse_message Function#

Splits a raw message at the first blank line into headers and body. Both CRLF and LF line endings are accepted; a message without a blank line has an empty body. Empty text or an invalid header block returns EBADMSG.

Manuscript
fn parse_message(raw String) Result[Message, Error] { ... }