Xo is experimental. The source is now public on GitHub, or try Xo in your browser.
Menu · mail

Docs

std/mail

On this page

Index

Types

Address

struct Address {
  name: Str
  address: Str
}

A mail address: the display name (decoded) and local@domain.

Source: std/mail.xo:6

Address.display

fn (a: Address) display() -> Str

"Ann Lee" <ann@example.com>, the name quoted or RFC 2047 encoded as needed (Address.String).

Source: std/mail.xo:26

MailErr

struct MailErr {
  msg: Str
}

Go’s error texts: mail: no address, mail: missing @ in addr-spec, …

Source: std/mail.xo:12

MailErr.display

fn (e: MailErr) display() -> Str

Source: std/mail.xo:16

Message

struct Message {
  headers: List[(Str, Str)]
  body: Bytes
}

A message (net/mail.Message): its header fields in order, each name in canonical form (Content-Type), continuation lines unfolded, and the body after the blank line.

Source: std/mail.xo:31

Message.header

fn (m: Message) header(name: Str) -> Str?

The first value of the header field name, any case (Header.Get).

Source: std/mail.xo:40

Functions

parse_address

fn parse_address(s: Str) -> Address ! MailErr

Ann Lee <ann@example.com>, ann@example.com (Ann), a quoted or RFC 2047 encoded name (mail.ParseAddress).

Source: std/mail.xo:20

parse_address_list

fn parse_address_list(s: Str) -> List[Address] ! MailErr

A comma separated list, groups (team: a@x, b@y;) flattened (mail.ParseAddressList).

Source: std/mail.xo:23

read_message

fn read_message(msg: Bytes) -> Message ! MailErr

The header and body of msg (mail.ReadMessage), with Go’s errors (malformed MIME header line: ...).

Source: std/mail.xo:38

parse_date

fn parse_date(s: Str) -> Time ! MailErr

An RFC 5322 date (mail.ParseDate): Mon, 02 Jan 2006 15:04:05 -0700, with the forms Go accepts (no weekday, one digit days, two digit years, no seconds, zone names, comments).

Source: std/mail.xo:44

compose

fn compose(from: Address, to: List[Address], subject: Str, text: Str, html: Str? = None, date: Time, id: Str) -> Bytes

A message ready for smtp.send (decision 0290): From, To, Subject (RFC 2047 encoded when not ASCII), Date, Message-ID <id>, MIME-Version, and a text/plain body, or multipart/alternative with an HTML part when html is given; bodies in quoted-printable, CRLF line endings.

Source: std/mail.xo:49

↑ index