Documentation
¶
Overview ¶
Package client wraps go-imap with reconnect logic and higher-level helpers.
Index ¶
- type Client
- func (c *Client) AppendMessage(folder string, msg *imap.Message) error
- func (c *Client) CreateMailbox(name string) (bool, error)
- func (c *Client) FetchMessageIDs(folder string) (map[string]bool, error)
- func (c *Client) FetchMessages(folder string) ([]*imap.Message, error)
- func (c *Client) FetchMessagesByIDs(folder string, targetIDs map[string]bool, tracker *progress.Tracker, ...) ([]*imap.Message, error)
- func (c *Client) GetDelimiter() string
- func (c *Client) ListMailboxes() ([]*MailboxInfo, error)
- func (c *Client) Reconnect() error
- func (c *Client) SafeSearch(criteria *imap.SearchCriteria) ([]uint32, error)
- func (c *Client) SafeSelect(mailbox string, readOnly bool) (*imap.MailboxStatus, error)
- func (c *Client) SetPrefix(p string)
- func (c *Client) SetProgressTracker(tracker ProgressTracker)
- func (c *Client) SetProgressWriter(pw ProgressWriter)
- type MailboxInfo
- type ProgressTracker
- type ProgressWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client embeds an IMAP client with retry-friendly helpers.
func New ¶
func New(addr, username, password string, workers int, verbose, useTLS bool, tlsConfig *tls.Config) (*Client, error)
New establishes a connection and logs into the IMAP server.
func (*Client) AppendMessage ¶
AppendMessage uploads a single message to the destination folder.
func (*Client) CreateMailbox ¶
CreateMailbox ensures the destination folder (and parents) exist on the server.
func (*Client) FetchMessageIDs ¶
FetchMessageIDs scans a folder and returns all message IDs.
func (*Client) FetchMessages ¶
FetchMessages retrieves full message envelopes and bodies for a folder.
func (*Client) FetchMessagesByIDs ¶
func (c *Client) FetchMessagesByIDs(folder string, targetIDs map[string]bool, tracker *progress.Tracker, totalToFetch int) ([]*imap.Message, error)
FetchMessagesByIDs retrieves full messages that match the given Message-IDs.
func (*Client) GetDelimiter ¶ added in v1.0.1
GetDelimiter returns the cached hierarchy delimiter for this server.
func (*Client) ListMailboxes ¶
func (c *Client) ListMailboxes() ([]*MailboxInfo, error)
ListMailboxes fetches all folders plus lightweight statistics for each.
func (*Client) Reconnect ¶
Reconnect tears down and rebuilds the underlying IMAP session with backoff.
func (*Client) SafeSearch ¶
func (c *Client) SafeSearch(criteria *imap.SearchCriteria) ([]uint32, error)
SafeSearch wraps IMAP search with automatic reconnects.
func (*Client) SafeSelect ¶
SafeSelect selects a mailbox and retries on transient connection errors.
func (*Client) SetProgressTracker ¶
func (c *Client) SetProgressTracker(tracker ProgressTracker)
SetProgressTracker sets an optional progress tracker for updating progress.
func (*Client) SetProgressWriter ¶
func (c *Client) SetProgressWriter(pw ProgressWriter)
SetProgressWriter sets the progress writer for logging.
type MailboxInfo ¶
MailboxInfo describes message counts and sizes for a single folder.
type ProgressTracker ¶
type ProgressTracker interface {
UpdateMessage(msg string)
UpdateTotal(total int64)
Increment(value int64)
MarkAsErrored()
}
ProgressTracker is a minimal interface for updating tracker messages.
type ProgressWriter ¶
type ProgressWriter interface {
Log(msg string, a ...interface{})
}
ProgressWriter is a minimal interface for progress tracking and logging. This avoids circular dependency with the progress package.