std/mail
On this page
Index
- type
Address- method
Address.display
- method
- type
MailErr- method
MailErr.display
- method
- type
Message- method
Message.header
- method
- fn
parse_address - fn
parse_address_list - fn
read_message - fn
parse_date - fn
compose
Types
Address
struct Address {
name: Str
address: Str
}A mail address: the display name (decoded) and local@domain.
Address.display
fn (a: Address) display() -> Str"Ann Lee" <ann@example.com>, the name quoted or RFC 2047 encoded as
needed (Address.String).
MailErr
struct MailErr {
msg: Str
}Go’s error texts: mail: no address, mail: missing @ in addr-spec, …
MailErr.display
fn (e: MailErr) display() -> StrMessage
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.
Message.header
fn (m: Message) header(name: Str) -> Str?The first value of the header field name, any case (Header.Get).
Functions
parse_address
fn parse_address(s: Str) -> Address ! MailErrAnn Lee <ann@example.com>, ann@example.com (Ann), a quoted or
RFC 2047 encoded name (mail.ParseAddress).
parse_address_list
fn parse_address_list(s: Str) -> List[Address] ! MailErrA comma separated list, groups (team: a@x, b@y;) flattened
(mail.ParseAddressList).
read_message
fn read_message(msg: Bytes) -> Message ! MailErrThe header and body of msg (mail.ReadMessage), with Go’s errors
(malformed MIME header line: ...).
parse_date
fn parse_date(s: Str) -> Time ! MailErrAn 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).
compose
fn compose(from: Address, to: List[Address], subject: Str, text: Str, html: Str? = None, date: Time, id: Str) -> BytesA 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.