Documentation
¶
Overview ¶
Package message defines the abstract view of an email message that Sieve tests and actions consult. Keeping it an interface lets the library stay independent of any particular mail-parsing library.
A net/mail-backed adapter is provided in this package for convenience.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder is a convenience for constructing Messages in tests and small host apps without going through net/mail.
func NewBuilder ¶
func NewBuilder() *Builder
func (*Builder) AddMIMEPart ¶
AddMIMEPart attaches a pre-built MIME part. Useful for tests that want to exercise the "mime" extension without parsing a multipart blob.
type MIMEPart ¶
type MIMEPart interface {
Header(name string) []string
AllHeaders() []Header
Body() io.Reader
ContentType() string
IsAttachment() bool
}
MIMEPart is the view of a single MIME body part used by the "mime" Sieve extension (RFC 5703). It exposes part-scope headers and the part body, plus a couple of convenience accessors that mirror what Sieve scripts most commonly want to ask about a part.
func NewMIMEPart ¶
NewMIMEPart builds a synthetic MIMEPart for tests and host code that already has the headers/body parsed.
type MIMEProvider ¶
type MIMEProvider interface {
MIMEParts() []MIMEPart
}
MIMEProvider is implemented by Messages that can enumerate their MIME structure. Returned parts are the *child* parts of the message in depth-first order; the root (the message itself) is NOT included — use the Message's own headers for that.
type Message ¶
type Message interface {
// Header returns all values for a header, in order, in their original
// form (i.e. with whitespace trimmed but otherwise unchanged).
Header(name string) []string
// AllHeaders returns every header in the order it appears in the
// message.
AllHeaders() []Header
// Body returns a reader over the message body (everything after the
// header/body separator). Each call returns a fresh reader positioned
// at the start of the body.
Body() io.Reader
// Size is the total size of the message in bytes (headers + body).
Size() int
// Envelope returns the SMTP envelope values for the named field
// ("from", "to"). It returns nil if no envelope is associated with
// the message.
Envelope(field string) []string
}
Message is the abstract view of a mail message used by Sieve tests. All header lookups are case-insensitive on the name.
func FromNetMail ¶
FromNetMail wraps a *net/mail.Message. The body is fully read into memory so that Body() and Size() are cheap and repeatable.