Documentation ¶
Index ¶
- Constants
- Variables
- func AddressListHTML(addr addr.AddressList) string
- func AddressListStrings(as addr.AddressList) []string
- func CompileAddress(name string, a interface{}) (addr.AddressList, error)
- func CompileField(name string, field interface{}) []string
- func CompileLabel(name string, label interface{}) []string
- type ActionsSummary
- type ColorPalette
- func (cp ColorPalette) Fcolor(out io.Writer, args ...string)
- func (cp ColorPalette) Fprintf(color string, out io.Writer, fmt string, args ...interface{})
- func (cp ColorPalette) Join(color string, args []string, d string) string
- func (cp ColorPalette) Scolor(args ...string) string
- func (cp ColorPalette) Sprintf(color string, fmt string, args ...interface{}) string
- type CompiledFolderRules
- type CompiledRule
- type CompiledRules
- type EnvRawRules
- type Filter
- func (fi *Filter) AllFolders() ([]string, error)
- func (fi *Filter) ApplyRule(m *Message, c *CompiledRule) ([]string, error)
- func (fi *Filter) ApplyRules(msg *Message, rules []*CompiledRule) ([]string, error)
- func (fi *Filter) LabelFolderMessages(actions ActionsSummary, folder string, rules CompiledRules) error
- func (fi *Filter) LabelMessage(folder, fn string) (ActionsSummary, error)
- func (fi *Filter) LabelMessages(onlyFolders []string) (ActionsSummary, error)
- func (fi *Filter) LimitFilterToRecent(limit time.Duration)
- func (fi *Filter) LimitSince() time.Time
- func (fi *Filter) Message(folder, fn string) (*Message, error)
- func (fi *Filter) Messages(folder string) ([]*Message, error)
- func (fi *Filter) RulesForFolder(f string) (CompiledRules, bool)
- func (fi *Filter) Vacuum(logf func(fmt string, opts ...interface{})) error
- type MailDirFolder
- func (f *MailDirFolder) Basename() string
- func (f *MailDirFolder) Message(fn string) (*Message, error)
- func (f *MailDirFolder) MessageDirPaths() []string
- func (f *MailDirFolder) Messages() ([]*Message, error)
- func (f *MailDirFolder) Path() string
- func (f *MailDirFolder) Root() string
- func (f *MailDirFolder) TempDirPath() string
- type MailDirSlurper
- func (r *MailDirSlurper) Filename() string
- func (r *MailDirSlurper) FlagSuffix() string
- func (r *MailDirSlurper) Folder() string
- func (r *MailDirSlurper) MoveTo(target *MailDirFolder) error
- func (r *MailDirSlurper) Remove() error
- func (r *MailDirSlurper) Replace() (*MailDirWriter, error)
- func (r *MailDirSlurper) Slurp() ([]byte, error)
- func (r *MailDirSlurper) Stat() (os.FileInfo, error)
- type MailDirWriter
- type Match
- type Message
- func (m *Message) AddKeyword(names ...string) error
- func (m *Message) AddressList(key string) (addr.AddressList, error)
- func (m *Message) BestAlternateFolder() (string, error)
- func (m *Message) CleanupKeywords() error
- func (m *Message) Date() (time.Time, error)
- func (m *Message) EmailMessage() (*mime.Message, error)
- func (m *Message) Filename() string
- func (m *Message) Folder() (string, error)
- func (m *Message) ForwardMessage(to addr.AddressList) ([]byte, error)
- func (m *Message) ForwardTo(tos addr.AddressList) error
- func (m *Message) HasKeyword(names ...string) (bool, error)
- func (m *Message) HasNonconformingKeywords() (bool, error)
- func (m *Message) Keywords() ([]string, error)
- func (m *Message) KeywordsSet() (km map[string]struct{}, err error)
- func (m *Message) MissingKeyword(names ...string) (bool, error)
- func (m *Message) MoveTo(root string, name string) error
- func (m *Message) Raw() ([]byte, error)
- func (m *Message) RemoveKeyword(names ...string) error
- func (m *Message) Save() error
- func (m *Message) Stat() (os.FileInfo, error)
- func (m *Message) Subject() (string, error)
- type MessageSlurper
- type RawRule
- type RawRules
- type Slurper
Constants ¶
const ( LocalLabelMailConf = ".label-mail.local.yml" LabelMailConf = ".label-mail.yml" )
const ( FromName = "Andrew Sterling Hanenkamp" ForwardedMessagePrefix = "---------- Forwarded message ---------" )
Variables ¶
var ( // DefaultMailDir is the usual maildir DefaultMailDir = path.Join(dotfiles.HomeDir, "Mail") // SkipFolder lists folders that are never filtered. SkipFolder = map[string]struct{}{ "gmail.Spam": struct{}{}, "gmail.Draft": struct{}{}, "gmail.Trash": struct{}{}, "gmail.Sent_Mail": struct{}{}, } )
var ( SASLUser = dotfiles.MustGetSecret("LABEL_MAIL_USERNAME") SASLPass = dotfiles.MustGetSecret("LABEL_MAIL_PASSWORD") )
var ( FromEmail = dotfiles.MustGetSecret("GIT_EMAIL_HOME") FromEmailAddress addr.AddressList )
var ( // UnwantedFolderSuffix mentions endings we want to strip during vacuuming. UnwantedFolderSuffix = []string{","} // UnwantedFolderPrefix mentions starts we want to strip during vacuuming. UnwantedFolderPrefix = []string{"+", "\\"} // UnwantedFolder mentions folders we want to strip during vacuuming. UnwantedFolder = []string{"[", "]", "Drafts", "Home_School", "Network", "Pseudo-Junk.Social", "Pseudo-Junk.Social_Network", "Social Network", "OtherJunk"} // UnwantedKeyword mentions remaps of folders we want to apply during // vacuuming. UnwantedKeyword = map[string][]string{ "JunkSocial": {"Network", "Pseudo-Junk.Social", "Pseudo-Junk/Social", "Psuedo-Junk/Social_Network", "Pseudo-Junk.Social_Network"}, "Teamwork": {"Discussion"}, "JunkOther": {"OtherJunk"}, } )
Functions ¶
func AddressListHTML ¶
func AddressListHTML(addr addr.AddressList) string
func AddressListStrings ¶
func AddressListStrings(as addr.AddressList) []string
func CompileAddress ¶
func CompileAddress(name string, a interface{}) (addr.AddressList, error)
func CompileField ¶
func CompileLabel ¶
Types ¶
type ActionsSummary ¶
ActionsSummary is the summary of actions taken while filtering to display to the user.
func (ActionsSummary) String ¶
func (actions ActionsSummary) String() string
String returns a nice tabular summary of the actions to the console.
fmt.Print(action)
type ColorPalette ¶
func (ColorPalette) Fprintf ¶
func (cp ColorPalette) Fprintf(color string, out io.Writer, fmt string, args ...interface{})
func (ColorPalette) Join ¶
func (cp ColorPalette) Join(color string, args []string, d string) string
func (ColorPalette) Scolor ¶
func (cp ColorPalette) Scolor(args ...string) string
type CompiledFolderRules ¶
type CompiledFolderRules map[string]CompiledRules
func (CompiledFolderRules) Add ¶
func (fcrs CompiledFolderRules) Add(folder string, cr *CompiledRule)
type CompiledRule ¶
type CompiledRule struct { Match OkayDate time.Time Clear []string Label []string Move string Forward addr.AddressList }
func (*CompiledRule) HasOkayDate ¶
func (c *CompiledRule) HasOkayDate() bool
func (*CompiledRule) IsClearing ¶
func (c *CompiledRule) IsClearing() bool
func (*CompiledRule) IsForwarding ¶
func (c *CompiledRule) IsForwarding() bool
func (*CompiledRule) IsLabeling ¶
func (c *CompiledRule) IsLabeling() bool
func (*CompiledRule) IsMoving ¶
func (c *CompiledRule) IsMoving() bool
func (*CompiledRule) NeedsOkayDate ¶
func (c *CompiledRule) NeedsOkayDate() bool
type CompiledRules ¶
type CompiledRules []*CompiledRule
func LoadRules ¶
func LoadRules() (CompiledRules, error)
func (CompiledRules) FolderRules ¶
func (crs CompiledRules) FolderRules() CompiledFolderRules
type EnvRawRules ¶
type Filter ¶
type Filter struct { MailRoot string // maildir to filter Rules CompiledRules // the compiled filter rules LimitRecent time.Duration // if set, only message files newer than this will be filtered Debug int // set the debug level, higher numbers mean even more verbose logging DryRun bool // when set, no changes will be made AllowSendingEmail bool // unless set, no email forwarding will be performed }
Filter represents the tools that parse and understand mail rules and filter folders and messages.
func (*Filter) AllFolders ¶
AllFolders lists all the maildir folders in the mail root.
func (*Filter) ApplyRule ¶
func (fi *Filter) ApplyRule(m *Message, c *CompiledRule) ([]string, error)
ApplyRule applies a single mail filter rule to a single mail message.
func (*Filter) ApplyRules ¶
func (fi *Filter) ApplyRules(msg *Message, rules []*CompiledRule) ([]string, error)
ApplyRules applies all the rules to a single mail message.
func (*Filter) LabelFolderMessages ¶
func (fi *Filter) LabelFolderMessages( actions ActionsSummary, folder string, rules CompiledRules, ) error
LabelFolderMessages performs filtering for a single maildir.
func (*Filter) LabelMessage ¶
func (fi *Filter) LabelMessage(folder, fn string) (ActionsSummary, error)
LabelMessage applies filters to a specific message.
func (*Filter) LabelMessages ¶
func (fi *Filter) LabelMessages(onlyFolders []string) (ActionsSummary, error)
LabelMessages applies filters to all applicable messages in the given list of folders.
func (*Filter) LimitFilterToRecent ¶
LimitFilterToRecent sets the LimitRecent time. When set and filtering folders, only messages with a modification time newer than LimitRecent will be filtered.
func (*Filter) LimitSince ¶
LimitSince returns the LimitSince setting set by LimitFilterToRecent.
func (*Filter) RulesForFolder ¶
func (fi *Filter) RulesForFolder(f string) (CompiledRules, bool)
RulesForFolder returns all the rules that apply to the given folder. The second return value is a boolean indicating whether this folder has any rules at all.
type MailDirFolder ¶
type MailDirFolder struct {
// contains filtered or unexported fields
}
MailDirFolder represents a single maildir folder in a mail root.
func NewMailDirFolder ¶
func NewMailDirFolder(root, folder string) *MailDirFolder
NewMailDirFolder constructs a MailDirFolder from a mail root and folder name.
func (*MailDirFolder) Basename ¶
func (f *MailDirFolder) Basename() string
Basename returns the folder name.
func (*MailDirFolder) Message ¶
func (f *MailDirFolder) Message(fn string) (*Message, error)
Message returns a single mail message object stored in the given file name.
func (*MailDirFolder) MessageDirPaths ¶
func (f *MailDirFolder) MessageDirPaths() []string
MessageDirPaths returns the directory paths that contain message files that can be worked with by these mail tools.
func (*MailDirFolder) Messages ¶
func (f *MailDirFolder) Messages() ([]*Message, error)
Messages returns all mail messages stored in the maildir.
func (*MailDirFolder) Path ¶
func (f *MailDirFolder) Path() string
Path returns the full path to the maildir folder.
func (*MailDirFolder) Root ¶
func (f *MailDirFolder) Root() string
Root returns the path to the mail root.
func (*MailDirFolder) TempDirPath ¶
func (f *MailDirFolder) TempDirPath() string
TempDirPath returns the directory path where messages being worked on are stored temporarily.
type MailDirSlurper ¶
type MailDirSlurper struct {
// contains filtered or unexported fields
}
func NewMailDirSlurper ¶
func NewMailDirSlurper(key, flags, rd string, folder *MailDirFolder) *MailDirSlurper
func NewMailDirSlurperWithStat ¶
func NewMailDirSlurperWithStat(key, flags, rd string, folder *MailDirFolder, fi *os.FileInfo) *MailDirSlurper
func (*MailDirSlurper) Filename ¶
func (r *MailDirSlurper) Filename() string
func (*MailDirSlurper) FlagSuffix ¶
func (r *MailDirSlurper) FlagSuffix() string
func (*MailDirSlurper) Folder ¶
func (r *MailDirSlurper) Folder() string
func (*MailDirSlurper) MoveTo ¶
func (r *MailDirSlurper) MoveTo(target *MailDirFolder) error
func (*MailDirSlurper) Remove ¶
func (r *MailDirSlurper) Remove() error
func (*MailDirSlurper) Replace ¶
func (r *MailDirSlurper) Replace() (*MailDirWriter, error)
func (*MailDirSlurper) Slurp ¶
func (r *MailDirSlurper) Slurp() ([]byte, error)
type MailDirWriter ¶
type MailDirWriter struct {
// contains filtered or unexported fields
}
func NewMailDirWriter ¶
func NewMailDirWriter(r *MailDirSlurper) (*MailDirWriter, error)
func (*MailDirWriter) Close ¶
func (w *MailDirWriter) Close() error
type Match ¶
type Match struct { Folder string `yaml:"folder"` From string `yaml:"from"` FromDomain string `yaml:"from_domain"` To string `yaml:"to"` ToDomain string `yaml:"to_domain"` Sender string `yaml:"sender"` DeliveredTo string `yaml:"delivered_to"` Subject string `yaml:"subject"` SubjectFold string `yaml:"isubject"` SubjectContains string `yaml:"subject_contains"` SubjectContainsFold string `yaml:"subject_icontains"` Contains string `yaml:"contains"` ContainsFold string `yaml:"icontains"` Days int `yaml:"days"` }
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
func NewFileMessage ¶
func NewMailDirMessage ¶
func NewMailDirMessage(key, flags, rd string, folder *MailDirFolder) *Message
func NewMailDirMessageWithStat ¶
func NewMailDirMessageWithStat(key, flags, rd string, folder *MailDirFolder, fi *os.FileInfo) *Message
func NewMessage ¶
func (*Message) AddKeyword ¶
func (*Message) AddressList ¶
func (m *Message) AddressList(key string) (addr.AddressList, error)
func (*Message) BestAlternateFolder ¶
func (*Message) CleanupKeywords ¶
func (*Message) ForwardMessage ¶
func (m *Message) ForwardMessage(to addr.AddressList) ([]byte, error)
func (*Message) HasNonconformingKeywords ¶
func (*Message) KeywordsSet ¶
func (*Message) RemoveKeyword ¶
type MessageSlurper ¶
type MessageSlurper struct {
// contains filtered or unexported fields
}
func NewMessageSlurper ¶
func NewMessageSlurper(filename string) *MessageSlurper
func (*MessageSlurper) Filename ¶
func (r *MessageSlurper) Filename() string
func (*MessageSlurper) Folder ¶
func (r *MessageSlurper) Folder() string
func (*MessageSlurper) Slurp ¶
func (r *MessageSlurper) Slurp() ([]byte, error)