Documentation
¶
Overview ¶
Package message holds the email types shared by the IMAP connector, the rules engine and the model adapters. Bodies live in memory only.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Raw ¶
type Raw struct {
Header []byte // BODY.PEEK[HEADER]
Text []byte // start of BODY.PEEK[TEXT], at most 64 KB
Flags []string // IMAP flags at fetch time, e.g. \Seen
InternalDate time.Time // when the server received it
Size int64 // RFC822.SIZE in bytes
HasAttachment bool // from BODYSTRUCTURE
AttachmentExts []string // lower-case, no dot, e.g. "pdf"
}
Raw is one message as fetched from the server with BODY.PEEK, before parsing.
type Summary ¶
type Summary struct {
AccountID int64
From string // address only
FromName string
FromDomain string
To []string
Cc []string
DeliveredTo []string
Subject string
Body string // plain text, control characters stripped, truncated to BODY_CHARS
Headers map[string][]string // canonical MIME header keys
ListID string
HasAttachment bool
AttachmentExts []string
SizeKB float64
ReceivedAt time.Time
// Signals.
IsContact bool // sender is in the contacts index
RepliedBefore bool // the user has sent mail to this sender
IsBulk bool // List-Unsubscribe or Precedence: bulk/list
IsNoreply bool // noreply@-style sender
DMARC string // pass | fail | none
}
Summary is the parsed email that conditions are matched against and that models are shown. Addresses and domains are lower-cased.
func Parse ¶
Parse turns a fetched message into the Summary that rules and models see. The body is plain text (HTML is converted), stripped of control and invisible characters and cut to bodyChars characters; zero or less keeps it whole. IsContact and RepliedBefore are left false: the caller fills them from the contacts index.
Raw.Text may stop mid-message, so a body that ends early is used as far as it goes.