Documentation
¶
Index ¶
- Constants
- Variables
- func FormatAddressList(addrs []*Address) (fields []interface{})
- func FormatParamList(params map[string]string) []interface{}
- func FormatStringList(list []string) (fields []interface{})
- func MakeHeaderMap(fs []*HeaderField) map[string][]*HeaderField
- func ParseString(f interface{}) (string, error)
- func ReadHeaderString(r *bufio.Reader) (string, error)
- type Address
- type BodyPartName
- type BodySectionName
- type BodyStructure
- type Date
- type DateTime
- type Envelope
- type FetchItem
- type Header
- type HeaderField
- type HeaderFields
- type Literal
- type MultipartReader
- type Part
- type PartSpecifier
- type RawString
Constants ¶
const ( // Refers to the entire part, including headers. EntireSpecifier PartSpecifier = "" // Refers to the header of the part. Must include the final CRLF delimiting // the header and the body. HeaderSpecifier = "HEADER" // Refers to the text body of the part, omitting the header. TextSpecifier = "TEXT" // Refers to the MIME Internet Message Body header. Must include the final // CRLF delimiting the header and the body. MIMESpecifier = "MIME" )
Part specifiers described in RFC 3501 page 55.
Variables ¶
CharsetReader, if non-nil, defines a function to generate charset-conversion readers, converting from the provided charset into UTF-8. Charsets are always lower-case. utf-8 and us-ascii charsets are handled by default. One of the the CharsetReader's result values must be non-nil.
Importing github.com/emersion/go-message/charset will set CharsetReader to a function that handles most common charsets. Alternatively, CharsetReader can be set to e.g. golang.org/x/net/html/charset.NewReaderLabel.
Functions ¶
func FormatAddressList ¶
func FormatAddressList(addrs []*Address) (fields []interface{})
Format an address list to fields.
func FormatParamList ¶
func FormatStringList ¶
func FormatStringList(list []string) (fields []interface{})
Convert a string list to a field list.
func MakeHeaderMap ¶
func MakeHeaderMap(fs []*HeaderField) map[string][]*HeaderField
func ParseString ¶
ParseString parses a string, which is either a literal, a quoted string or an atom.
Types ¶
type Address ¶
type Address struct {
// The personal name.
PersonalName string
// The SMTP at-domain-list (source route).
AtDomainList string
// The mailbox name.
MailboxName string
// The host name.
HostName string
}
An address.
func ParseAddressList ¶
func ParseAddressList(fields []interface{}) (addrs []*Address)
Parse an address list from fields.
type BodyPartName ¶
type BodyPartName struct {
// The specifier of the requested part.
Specifier PartSpecifier
// The part path. Parts indexes start at 1.
Path []int
// If Specifier is HEADER, contains header fields that will/won't be returned,
// depending of the value of NotFields.
Fields []string
// If set to true, Fields is a blacklist of fields instead of a whitelist.
NotFields bool
}
A body part name.
type BodySectionName ¶
type BodySectionName struct {
BodyPartName
// If set to true, do not implicitly set the \Seen flag.
Peek bool
// The substring of the section requested. The first value is the position of
// the first desired octet and the second value is the maximum number of
// octets desired.
Partial []int
// contains filtered or unexported fields
}
A body section name. See RFC 3501 page 55.
type BodyStructure ¶
type BodyStructure struct {
// The MIME type.
MimeType string
// The MIME subtype.
MimeSubType string
// The MIME parameters.
Params map[string]string
// The Content-Id header.
Id string
// The Content-Description header.
Description string
// The Content-Encoding header.
Encoding string
// The Content-Length header.
Size int
// The children parts, if multipart.
Parts []*BodyStructure
// The envelope, if message/rfc822.
Envelope *Envelope
// The body structure, if message/rfc822.
BodyStructure *BodyStructure
// The number of lines, if text or message/rfc822.
Lines uint32
// True if the body structure contains extension data.
Extended bool
// The Content-Disposition header field value.
Disposition string
// The Content-Disposition header field parameters.
DispositionParams map[string]string
// The Content-Language header field, if multipart.
Language []string
// The content URI, if multipart.
Location []string
// The MD5 checksum.
MD5 string
}
A body structure. See RFC 3501 page 74.
func FetchBodyStructure ¶
FetchBodyStructure computes a message's body structure from its content.
func (*BodyStructure) Format ¶
func (bs *BodyStructure) Format() (fields []interface{})
func (*BodyStructure) ToString ¶
func (bs *BodyStructure) ToString() string
type Envelope ¶
type Envelope struct {
// The message date.
Date time.Time
// The message subject.
Subject string
// The From header addresses.
From []*Address
// The message senders.
Sender []*Address
// The Reply-To header addresses.
ReplyTo []*Address
// The To header addresses.
To []*Address
// The Cc header addresses.
Cc []*Address
// The Bcc header addresses.
Bcc []*Address
// The In-Reply-To header. Contains the parent Message-Id.
InReplyTo string
// The Message-Id header.
MessageId string
}
A message envelope, ie. message metadata from its headers. See RFC 3501 page 77.
type Header ¶
type Header struct {
// contains filtered or unexported fields
}
A Header represents the key-value pairs in a message header.
The header representation is idempotent: if the header can be read and written, the result will be exactly the same as the original (including whitespace). This is required for e.g. DKIM.
Mutating the header is restricted: the only two allowed operations are inserting a new header field at the top and deleting a header field. This is again necessary for DKIM.
func NewHeader ¶
func NewHeader(fs []*HeaderField) Header
func ReadHeader ¶
ReadHeader reads a MIME header from r. The header is a sequence of possibly continued Key: Value lines ending in a blank line.
type HeaderField ¶
type HeaderField struct {
// contains filtered or unexported fields
}
type HeaderFields ¶
type HeaderFields struct {
// contains filtered or unexported fields
}
type Literal ¶
A literal, as defined in RFC 3501 section 4.3.
type MultipartReader ¶
type MultipartReader struct {
// contains filtered or unexported fields
}
MultipartReader is an iterator over parts in a MIME multipart body. MultipartReader's underlying parser consumes its input as needed. Seeking isn't supported.
func NewMultipartReader ¶
func NewMultipartReader(r io.Reader, boundary string) *MultipartReader
NewMultipartReader creates a new multipart reader reading from r using the given MIME boundary.
The boundary is usually obtained from the "boundary" parameter of the message's "Content-Type" header. Use mime.ParseMediaType to parse such headers.
func (*MultipartReader) NextPart ¶
func (r *MultipartReader) NextPart() (*Part, error)
NextPart returns the next part in the multipart or an error. When there are no more parts, the error io.EOF is returned.
type PartSpecifier ¶
type PartSpecifier string
A PartSpecifier specifies which parts of the MIME entity should be returned.