client

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package client wraps go-imap with reconnect logic and higher-level helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*client.Client
	// contains filtered or unexported fields
}

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

func (c *Client) AppendMessage(folder string, msg *imap.Message) error

AppendMessage uploads a single message to the destination folder.

func (*Client) CreateMailbox

func (c *Client) CreateMailbox(name string) (bool, error)

CreateMailbox ensures the destination folder (and parents) exist on the server.

func (*Client) FetchMessageIDs

func (c *Client) FetchMessageIDs(folder string) (map[string]bool, error)

FetchMessageIDs scans a folder and returns all message IDs.

func (*Client) FetchMessages

func (c *Client) FetchMessages(folder string) ([]*imap.Message, error)

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

func (c *Client) GetDelimiter() string

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

func (c *Client) Reconnect() error

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

func (c *Client) SafeSelect(mailbox string, readOnly bool) (*imap.MailboxStatus, error)

SafeSelect selects a mailbox and retries on transient connection errors.

func (*Client) SetPrefix

func (c *Client) SetPrefix(p string)

SetPrefix configures the log prefix used in progress messages.

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

type MailboxInfo struct {
	Name     string
	Messages uint32
	Size     uint64
}

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.

Jump to

Keyboard shortcuts

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