mail

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const DoctorProbeTimeout = 3 * time.Second

DoctorProbeTimeout bounds each read-only Mail.app diagnostic. Keeping the probes separate lets doctor report partial diagnostics when one Mail.app API surface is unavailable.

Variables

This section is empty.

Functions

func ClearRecentMessages added in v1.2.1

func ClearRecentMessages() error

func RecordRecentMessage added in v1.2.1

func RecordRecentMessage(message Message, action string) error

func RecordRecentSearchResults added in v1.2.1

func RecordRecentSearchResults(messages []Message, query string) error

func RemoveRecentMessage added in v1.2.2

func RemoveRecentMessage(account, messageID string) error

func UpdateRecentMessageLocation added in v1.2.1

func UpdateRecentMessageLocation(account, messageID, mailbox, action string) error

func ValidateRuleInput added in v1.3.0

func ValidateRuleInput(input RuleInput) error

ValidateRuleInput verifies the complete input contract before a rule is created. Callers should use it for dry runs as well as live rule creation.

Types

type Account

type Account struct {
	ID           string
	Name         string
	EmailAddress string
	AccountType  string
	UserName     string
	Enabled      bool
}

type Attachment

type Attachment struct {
	Index    int
	Name     string
	FileSize int
	MimeType string
}

type AutomationLockTimeoutError added in v1.3.0

type AutomationLockTimeoutError struct {
	Engine  string
	Timeout time.Duration
}

AutomationLockTimeoutError reports a command that could not enter the serialized automation queue within its bounded wait period.

func (*AutomationLockTimeoutError) Error added in v1.3.0

func (*AutomationLockTimeoutError) Unwrap added in v1.3.0

func (e *AutomationLockTimeoutError) Unwrap() error

type AutomationTimeoutError added in v1.3.0

type AutomationTimeoutError struct {
	Engine  string
	Timeout time.Duration
}

AutomationTimeoutError reports a bounded Mail.app automation invocation that did not complete. It unwraps to context.DeadlineExceeded so callers can classify it with errors.Is, and exposes the engine and configured timeout for human-readable diagnostics.

func (*AutomationTimeoutError) Error added in v1.3.0

func (e *AutomationTimeoutError) Error() string

func (*AutomationTimeoutError) Unwrap added in v1.3.0

func (e *AutomationTimeoutError) Unwrap() error

type Client

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

func NewClient

func NewClient() *Client

func (*Client) ArchiveMessage

func (c *Client) ArchiveMessage(accountName, mailboxName, messageID string) error

func (*Client) ArchiveMessageWithDestination added in v1.2.1

func (c *Client) ArchiveMessageWithDestination(accountName, mailboxName, messageID string) (string, error)

func (*Client) BulkArchiveMessages

func (c *Client) BulkArchiveMessages(requests []struct {
	AccountName string
	MailboxName string
	MessageID   string
}) error

func (*Client) BulkDeleteMessages

func (c *Client) BulkDeleteMessages(requests []struct {
	AccountName string
	MailboxName string
	MessageID   string
}) error

func (*Client) BulkFlagMessages

func (c *Client) BulkFlagMessages(requests []struct {
	AccountName string
	MailboxName string
	MessageID   string
	Flagged     bool
}) error

func (*Client) BulkMarkMessages

func (c *Client) BulkMarkMessages(requests []struct {
	AccountName string
	MailboxName string
	MessageID   string
	Read        bool
}) error

func (*Client) BulkMoveMessages

func (c *Client) BulkMoveMessages(requests []struct {
	AccountName   string
	SourceMailbox string
	MessageID     string
	TargetMailbox string
}) error

func (*Client) CheckAccountAccess added in v1.3.0

func (c *Client) CheckAccountAccess(timeout time.Duration) (int, error)

CheckAccountAccess verifies read access to the account collection and returns only its count, not account names or addresses.

func (*Client) CheckAutomationAccess added in v1.3.0

func (c *Client) CheckAutomationAccess(timeout time.Duration) error

CheckAutomationAccess verifies that the automation bridge can read a harmless Mail.app property. It is deliberately separate from the bridge probe because an installed application can still deny automation access.

func (*Client) CheckEnvelopeIndex added in v1.2.1

func (c *Client) CheckEnvelopeIndex() error

func (*Client) CheckMailBridge added in v1.3.0

func (c *Client) CheckMailBridge() error

CheckMailBridge verifies that the local Mail.app bundle is present without issuing an Apple Event. Automation permission is checked independently so a denied permission cannot be mistaken for a missing Mail installation.

func (*Client) CreateDraft

func (c *Client) CreateDraft(input DraftInput) (*Message, error)

func (*Client) CreateRule

func (c *Client) CreateRule(input RuleInput) (*Rule, error)

func (*Client) DeleteDraft

func (c *Client) DeleteDraft(accountName, draftID string) error

func (*Client) DeleteMessage

func (c *Client) DeleteMessage(accountName, mailboxName, messageID string) error

func (*Client) DeleteMessageResolved added in v1.1.1

func (c *Client) DeleteMessageResolved(accountName, mailboxName, messageID string) error

func (*Client) DeleteRule

func (c *Client) DeleteRule(name string) error

func (*Client) FlagMessage

func (c *Client) FlagMessage(accountName, mailboxName, messageID string, flagged bool) error

func (*Client) GetAccounts

func (c *Client) GetAccounts() ([]Account, error)

func (*Client) GetAccountsJSON

func (c *Client) GetAccountsJSON() ([]Account, error)

func (*Client) GetAllMailboxes

func (c *Client) GetAllMailboxes() ([]Mailbox, error)

func (*Client) GetAttachmentsJSON

func (c *Client) GetAttachmentsJSON(accountName, mailboxName, messageID string) ([]Attachment, error)

func (*Client) GetDraft

func (c *Client) GetDraft(accountName, draftID string) (*Message, error)

func (*Client) GetMailboxes

func (c *Client) GetMailboxes(accountName string) ([]Mailbox, error)

func (*Client) GetMailboxesJSON

func (c *Client) GetMailboxesJSON(accountName string) ([]Mailbox, error)

func (*Client) GetMessageDetailsJSON

func (c *Client) GetMessageDetailsJSON(accountName, mailboxName, messageID string) (*Message, error)

func (*Client) GetMessages

func (c *Client) GetMessages(accountName, mailboxName string, limit int) ([]Message, error)

func (*Client) GetMessagesFromMultipleMailboxes

func (c *Client) GetMessagesFromMultipleMailboxes(requests []struct {
	AccountName string
	MailboxName string
	Limit       int
	Offset      int
	UnreadOnly  bool
	FlaggedOnly bool
	WithContent bool
	Since       string
}) ([]Message, error)

func (*Client) GetMessagesJSON

func (c *Client) GetMessagesJSON(accountName, mailboxName string, limit, offset int, unreadOnly, flaggedOnly, withContent bool, since string) ([]Message, error)

func (*Client) GetMultipleMessageDetails

func (c *Client) GetMultipleMessageDetails(requests []struct {
	AccountName string
	MailboxName string
	MessageID   string
}) ([]*Message, error)

func (*Client) GetUnifiedMessagesJSON

func (c *Client) GetUnifiedMessagesJSON(mailboxType string, limit, offset int, withContent bool) ([]Message, error)

func (*Client) GetUnreadCount

func (c *Client) GetUnreadCount() (int, error)

func (*Client) ListRules

func (c *Client) ListRules() ([]Rule, error)

func (*Client) ListSignatures

func (c *Client) ListSignatures(includeContent bool) ([]Signature, error)

func (*Client) ListSmartMailboxes

func (c *Client) ListSmartMailboxes() ([]SmartMailbox, error)

func (*Client) MarkMessageAsRead

func (c *Client) MarkMessageAsRead(accountName, mailboxName, messageID string, read bool) error

func (*Client) MoveMessage

func (c *Client) MoveMessage(accountName, sourceMailbox, messageID, targetMailbox string) error

func (*Client) RecordRecentEnvelope added in v1.2.1

func (c *Client) RecordRecentEnvelope(accountName, mailboxName, messageID, action string) error

func (*Client) RunLiveProbe added in v1.3.0

func (c *Client) RunLiveProbe(timeout time.Duration) error

RunLiveProbe performs a bounded, read-only query against Mail.app. It is intentionally independent of account enumeration so doctor does not infer live bridge health from a cached or index-backed result.

func (*Client) SaveAttachment

func (c *Client) SaveAttachment(accountName, mailboxName, messageID, attachmentName, savePath string) error

func (*Client) SaveAttachmentByIndex

func (c *Client) SaveAttachmentByIndex(accountName, mailboxName, messageID, attachmentName string, index int, savePath string) error

func (*Client) SearchMessages

func (c *Client) SearchMessages(query string, limit int) ([]Message, error)

func (*Client) SearchMessagesJSON

func (c *Client) SearchMessagesJSON(query string, accountName string, mailboxName string, limit int) ([]Message, error)

func (*Client) SearchMessagesJSONSince added in v1.1.2

func (c *Client) SearchMessagesJSONSince(query string, accountName string, mailboxName string, limit int, since string) ([]Message, error)

func (*Client) SearchMessagesJSONSinceWithOptions added in v1.3.0

func (c *Client) SearchMessagesJSONSinceWithOptions(query string, accountName string, mailboxName string, limit int, since string, options SearchOptions) (SearchResult, error)

SearchMessagesJSONSinceWithOptions searches the requested mailbox scope and records its completeness. Cross-mailbox searches fail closed unless AllowPartial is set.

func (*Client) SendDraft

func (c *Client) SendDraft(accountName, draftID string) error

func (*Client) SendMessage

func (c *Client) SendMessage(accountName, subject, body string, to, cc, bcc, attachments []string) error

func (*Client) SetRuleEnabled

func (c *Client) SetRuleEnabled(name string, enabled bool) error

func (*Client) SignatureByName

func (c *Client) SignatureByName(name string) (*Signature, error)

func (*Client) SyncAccount

func (c *Client) SyncAccount(accountName string) error

func (*Client) SyncAllAccounts

func (c *Client) SyncAllAccounts() error

func (*Client) UpdateDraft

func (c *Client) UpdateDraft(accountName, draftID string, input DraftInput) (*Message, error)

type DraftInput

type DraftInput struct {
	Account     string   `json:"account"`
	Subject     string   `json:"subject"`
	Body        string   `json:"body"`
	To          []string `json:"to"`
	Cc          []string `json:"cc,omitempty"`
	Bcc         []string `json:"bcc,omitempty"`
	Attachments []string `json:"attachments,omitempty"`
	SubjectSet  bool     `json:"-"`
	BodySet     bool     `json:"-"`
}

type Mailbox

type Mailbox struct {
	Name        string
	UnreadCount int
	TotalCount  int
	Account     string
}

type Message

type Message struct {
	ID            string
	Subject       string
	Sender        string
	DateSent      string
	DateReceived  string
	Read          bool
	Flagged       bool
	Deleted       bool
	MessageSize   int
	Content       string
	Mailbox       string
	Account       string
	ToRecipients  []string
	CcRecipients  []string
	BccRecipients []string
}

func SearchRecentMessages added in v1.2.1

func SearchRecentMessages(query, accountName, mailboxName string, limit int, since string) ([]Message, error)

type PartialSearchError added in v1.3.0

type PartialSearchError struct {
	Result SearchResult
}

PartialSearchError means one or more mailboxes were unavailable. Its Result is populated so callers that deliberately opted in can inspect the precise scope of the incomplete result.

func (*PartialSearchError) Error added in v1.3.0

func (e *PartialSearchError) Error() string

type RecentMessage added in v1.2.1

type RecentMessage struct {
	ID              string   `json:"id"`
	Account         string   `json:"account"`
	Mailbox         string   `json:"mailbox"`
	OriginalMailbox string   `json:"originalMailbox,omitempty"`
	Subject         string   `json:"subject"`
	Sender          string   `json:"sender"`
	DateReceived    string   `json:"dateReceived"`
	DateSent        string   `json:"dateSent"`
	Read            bool     `json:"read"`
	Flagged         bool     `json:"flagged"`
	Deleted         bool     `json:"deleted,omitempty"`
	MessageSize     int      `json:"messageSize"`
	SearchTerms     []string `json:"searchTerms,omitempty"`
	LastAction      string   `json:"lastAction"`
	LastSeenAt      string   `json:"lastSeenAt"`
}

func ResolveRecentMessage added in v1.2.1

func ResolveRecentMessage(selector, accountName, mailboxName string) (*RecentMessage, error)

type Rule

type Rule struct {
	Name       string   `json:"name"`
	Enabled    bool     `json:"enabled"`
	Conditions []string `json:"conditions,omitempty"`
	Actions    []string `json:"actions,omitempty"`
}

type RuleInput

type RuleInput struct {
	Name            string   `json:"name"`
	Account         string   `json:"account,omitempty"`
	FromDomain      string   `json:"fromDomain,omitempty"`
	MoveTo          string   `json:"moveTo"`
	Enabled         bool     `json:"enabled"`
	SubjectContains []string `json:"subjectContains,omitempty"`
	MarkRead        bool     `json:"markRead,omitempty"`
}

type SearchMailbox added in v1.3.0

type SearchMailbox struct {
	Account string `json:"account"`
	Mailbox string `json:"mailbox"`
}

SearchMailbox identifies a mailbox included in a search attempt.

type SearchMailboxFailure added in v1.3.0

type SearchMailboxFailure struct {
	Account string `json:"account"`
	Mailbox string `json:"mailbox"`
	Error   string `json:"error"`
}

SearchMailboxFailure records a mailbox that could not be searched. Error is diagnostic metadata rather than a machine-stable error code.

type SearchOptions added in v1.3.0

type SearchOptions struct {
	AllowPartial bool
}

SearchOptions controls the safety contract for searches that span multiple mailboxes. A partial result is unsafe for workflows such as duplicate detection, so callers must explicitly opt in before receiving one.

type SearchResult added in v1.3.0

type SearchResult struct {
	Messages          []Message              `json:"messages"`
	Complete          bool                   `json:"complete"`
	SearchedMailboxes []SearchMailbox        `json:"searchedMailboxes"`
	FailedMailboxes   []SearchMailboxFailure `json:"failedMailboxes"`
}

SearchResult is the structured search contract. Complete is false whenever at least one requested mailbox failed to return a result.

type Signature

type Signature struct {
	Name    string `json:"name"`
	Account string `json:"account,omitempty"`
	Content string `json:"content,omitempty"`
}

type SmartMailbox

type SmartMailbox struct {
	Name       string `json:"name"`
	Account    string `json:"account,omitempty"`
	Unread     int    `json:"unreadCount,omitempty"`
	TotalCount int    `json:"totalCount,omitempty"`
}

Jump to

Keyboard shortcuts

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