@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.
type Address {
address String
name String = ""
}Address.address#
The local@domain address without angle brackets.
address StringAddress.name#
Display name with quotes removed; empty when none was given.
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.
fn to_string() StringMessage Type#
A parsed message: header fields and the body after the first blank line.
type Message {
headers Headers
body String
}Message.body#
Body text exactly as written after the blank line, with line endings kept.
body StringMessage.headers#
Header block with folded lines joined.
headers Headersdecode_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.
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.
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.
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.
fn parse_message(raw String) Result[Message, Error] { ... }