component

package
v0.0.0-...-c7a3bb2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
var CharsetReader func(charset string, input io.Reader) (io.Reader, error)

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 FormatParamList(params map[string]string) []interface{}

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

func ParseString(f interface{}) (string, error)

ParseString parses a string, which is either a literal, a quoted string or an atom.

func ReadHeaderString

func ReadHeaderString(r *bufio.Reader) (string, error)

ReadHeader reads a MIME header from r. The header is a sequence of possibly continued Key: Value lines ending in a blank line.

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.

func (*Address) Format

func (addr *Address) Format() []interface{}

Format an address to fields.

func (*Address) Parse

func (addr *Address) Parse(fields []interface{}) error

Parse an address 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

func FetchBodyStructure(header Header, body io.Reader, extended bool) (*BodyStructure, error)

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 Date

type Date time.Time

type DateTime

type DateTime time.Time

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.

func (*Envelope) Format

func (e *Envelope) Format() (fields []interface{})

Format an envelope to fields.

type FetchItem

type FetchItem string

A FetchItem is a message data item that can be fetched.

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

func ReadHeader(r *bufio.Reader) (Header, error)

ReadHeader reads a MIME header from r. The header is a sequence of possibly continued Key: Value lines ending in a blank line.

func (*Header) Get

func (h *Header) Get(k string) string

Get gets the first value associated with the given key. If there are no values associated with the key, Get returns "".

type HeaderField

type HeaderField struct {
	// contains filtered or unexported fields
}

type HeaderFields

type HeaderFields struct {
	// contains filtered or unexported fields
}

type Literal

type Literal interface {
	io.Reader

	// Len returns the number of bytes of the literal.
	Len() int
}

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 Part

type Part struct {
	Header Header

	Content string
	// contains filtered or unexported fields
}

A Part represents a single part in a multipart body.

func (*Part) Close

func (p *Part) Close() error

func (*Part) Read

func (p *Part) Read(d []byte) (n int, err error)

Read reads the body of a part, after its headers and before the next part (if any) begins.

type PartSpecifier

type PartSpecifier string

A PartSpecifier specifies which parts of the MIME entity should be returned.

type RawString

type RawString string

A raw string.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL