Documentation
¶
Index ¶
- func ComposeRFC5322(from, to, subject, body string) (string, []byte)
- func FolderName(mailboxName string) string
- func ParseEnvelope(uid uint32, env *imap.Envelope, flags []imap.Flag) email.Message
- type AttachmentData
- type BodyResult
- type ConnectionStatusMsg
- type Coordinator
- func (c *Coordinator) DeleteFolder(acctEmail, folder string) tea.Cmd
- func (c *Coordinator) DeleteMessage(acctEmail, folder string, uid uint32) tea.Cmd
- func (c *Coordinator) DeleteMessages(acctEmail, folder string, uids []uint32) tea.Cmd
- func (c *Coordinator) DisconnectAll()
- func (c *Coordinator) ExportMessages(acctEmail, folder string, messages []email.Message) tea.Cmd
- func (c *Coordinator) FetchBody(acctEmail, folder string, uid uint32) tea.Cmd
- func (c *Coordinator) MarkRead(acctEmail, folder string, uid uint32) tea.Cmd
- func (c *Coordinator) ResolveCredentials() []error
- func (c *Coordinator) RestoreFromTrash(acctEmail string, uids []uint32, dstFolder string) tea.Cmd
- func (c *Coordinator) RetryPendingOps() tea.Cmd
- func (c *Coordinator) SaveAttachments(acctEmail, folder string, uid uint32, attachments []email.Attachment) tea.Cmd
- func (c *Coordinator) SendAndArchive(acctEmail string, req SendRequest) tea.Cmd
- func (c *Coordinator) SetProgram(p *tea.Program)
- func (c *Coordinator) SyncAll() tea.Cmd
- func (c *Coordinator) SyncFolder(acctEmail, folder string) tea.Cmd
- type DeleteProgressMsg
- type DeleteResult
- type ExportProgressMsg
- type FetchBodyRequest
- type FetchBodyResult
- type FolderListResult
- type IMAPWorker
- func (w *IMAPWorker) AppendToFolder(folder string, message []byte, flags []imap.Flag) error
- func (w *IMAPWorker) Connect() error
- func (w *IMAPWorker) DeleteMailbox(folder string) error
- func (w *IMAPWorker) Disconnect()
- func (w *IMAPWorker) FetchBody(folder string, uid uint32) (BodyResult, error)
- func (w *IMAPWorker) FetchBodyDirect(folder string, uid uint32) (BodyResult, error)
- func (w *IMAPWorker) FetchRawMessage(folder string, uid uint32) ([]byte, error)
- func (w *IMAPWorker) FolderStatus(folder string) (uidNext uint32, uidValidity uint32, err error)
- func (w *IMAPWorker) Idle(folder string, timeout time.Duration) (bool, error)
- func (w *IMAPWorker) IsConnected() bool
- func (w *IMAPWorker) ListMailboxes() ([]string, error)
- func (w *IMAPWorker) MarkRead(folder string, uid uint32) error
- func (w *IMAPWorker) MarkReadBatch(folder string, uids []uint32) error
- func (w *IMAPWorker) MoveToFolder(srcFolder string, uid uint32, dstFolder string) error
- func (w *IMAPWorker) MoveToFolderBatch(srcFolder string, uids []uint32, dstFolder string) error
- func (w *IMAPWorker) MoveToTrash(folder string, uid uint32) error
- func (w *IMAPWorker) MoveToTrashBatch(folder string, uids []uint32, onProgress func(done, total int)) error
- func (w *IMAPWorker) Ping() bool
- func (w *IMAPWorker) SetWantedFetchUID(uid uint32)
- func (w *IMAPWorker) SyncFolder(folder string, onProgress ...func(fetched int)) (int, error)
- type NewMailMsg
- type RestoreResult
- type SMTPWorker
- type SendRequest
- type SendResult
- type SyncAccountCompleteMsg
- type SyncAllCompleteMsg
- type SyncProgressMsg
- type SyncRequest
- type SyncResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComposeRFC5322 ¶
ComposeRFC5322 builds a properly formatted RFC 5322 email message. Returns the message ID and the raw message bytes.
func FolderName ¶
FolderName maps an IMAP mailbox name to a display name.
Types ¶
type AttachmentData ¶
AttachmentData holds the raw bytes of an extracted attachment.
func ExtractAttachmentData ¶
func ExtractAttachmentData(data []byte) ([]AttachmentData, error)
ExtractAttachmentData parses a raw RFC 5322 message and returns the binary data for all attachment parts.
type BodyResult ¶
type BodyResult struct {
Text string
HTML string
Attachments []email.Attachment
}
BodyResult holds both the plain-text and raw HTML versions of an email body, plus any attachment metadata discovered during parsing.
func ParseBody ¶
func ParseBody(data []byte) (BodyResult, error)
ParseBody extracts text and HTML content from a message. Returns a BodyResult with a displayable Text, the raw HTML (for "open in browser"), and metadata for any attachments found.
type ConnectionStatusMsg ¶
ConnectionStatusMsg reports the connection state of an account.
type Coordinator ¶
type Coordinator struct {
// contains filtered or unexported fields
}
Coordinator manages IMAP and SMTP workers for all configured accounts.
func NewCoordinator ¶
func NewCoordinator(cfg config.Config, store *cache.SQLiteStore) *Coordinator
NewCoordinator creates a coordinator for the given config and store.
func (*Coordinator) DeleteFolder ¶
func (c *Coordinator) DeleteFolder(acctEmail, folder string) tea.Cmd
DeleteFolder returns a tea.Cmd that deletes a mailbox on the IMAP server and removes it from cache.
func (*Coordinator) DeleteMessage ¶
func (c *Coordinator) DeleteMessage(acctEmail, folder string, uid uint32) tea.Cmd
DeleteMessage returns a tea.Cmd that moves a message to Trash via IMAP.
func (*Coordinator) DeleteMessages ¶
func (c *Coordinator) DeleteMessages(acctEmail, folder string, uids []uint32) tea.Cmd
DeleteMessages returns a tea.Cmd that moves multiple messages to Trash via IMAP in a single batch. The operation is queued so it can be retried on reconnect.
func (*Coordinator) DisconnectAll ¶
func (c *Coordinator) DisconnectAll()
DisconnectAll cleanly disconnects all workers.
func (*Coordinator) ExportMessages ¶ added in v0.9.0
ExportMessages exports one or more messages to a ZIP file in ~/Downloads. Each message gets a folder with metadata.txt, message.txt, message.html, and attachments.
func (*Coordinator) FetchBody ¶
func (c *Coordinator) FetchBody(acctEmail, folder string, uid uint32) tea.Cmd
FetchBody returns a tea.Cmd that lazily fetches a message body.
func (*Coordinator) MarkRead ¶
func (c *Coordinator) MarkRead(acctEmail, folder string, uid uint32) tea.Cmd
MarkRead returns a tea.Cmd that marks a message as read on the IMAP server. The operation is queued so it can be retried if the connection is lost.
func (*Coordinator) ResolveCredentials ¶
func (c *Coordinator) ResolveCredentials() []error
ResolveCredentials resolves and caches credentials for all accounts. Should be called before SyncAll.
func (*Coordinator) RestoreFromTrash ¶ added in v0.9.0
RestoreFromTrash moves messages from Trash back to the destination folder via IMAP.
func (*Coordinator) RetryPendingOps ¶
func (c *Coordinator) RetryPendingOps() tea.Cmd
RetryPendingOps retries any pending or failed operations from the queue.
func (*Coordinator) SaveAttachments ¶
func (c *Coordinator) SaveAttachments(acctEmail, folder string, uid uint32, attachments []email.Attachment) tea.Cmd
SaveAttachments fetches the raw message and saves the specified attachments to ~/Downloads. Only attachments whose filename matches one in the provided list are saved.
func (*Coordinator) SendAndArchive ¶
func (c *Coordinator) SendAndArchive(acctEmail string, req SendRequest) tea.Cmd
SendAndArchive returns a tea.Cmd that sends an email via SMTP and appends it to the Sent folder via IMAP. The operation is queued so it can be retried on reconnect.
func (*Coordinator) SetProgram ¶
func (c *Coordinator) SetProgram(p *tea.Program)
SetProgram sets the bubbletea program reference for sending async progress messages.
func (*Coordinator) SyncAll ¶
func (c *Coordinator) SyncAll() tea.Cmd
SyncAll returns a tea.Cmd that syncs all accounts concurrently. Each account reports its own completion via SyncAccountCompleteMsg, and a final SyncAllCompleteMsg is sent when all are done.
func (*Coordinator) SyncFolder ¶
func (c *Coordinator) SyncFolder(acctEmail, folder string) tea.Cmd
SyncFolder returns a tea.Cmd that syncs a specific folder.
type DeleteProgressMsg ¶
DeleteProgressMsg reports incremental progress during batch deletion.
type DeleteResult ¶
DeleteResult is the result of deleting a message via IMAP.
type ExportProgressMsg ¶ added in v0.9.0
ExportProgressMsg reports incremental progress during batch export.
type FetchBodyRequest ¶
FetchBodyRequest requests lazy-loading a message body.
type FetchBodyResult ¶
type FetchBodyResult struct {
Account string
Folder string
UID uint32
Body string
HTMLBody string
Attachments []email.Attachment
Err error
}
FetchBodyResult is the result of fetching a message body.
type FolderListResult ¶
FolderListResult holds the folders discovered for an account.
type IMAPWorker ¶
type IMAPWorker struct {
// contains filtered or unexported fields
}
IMAPWorker manages a single IMAP connection for one account.
func NewIMAPWorker ¶
func NewIMAPWorker(acct config.AccountConfig, creds *auth.Credentials, store *cache.SQLiteStore) *IMAPWorker
NewIMAPWorker creates a new IMAP worker for the given account.
func (*IMAPWorker) AppendToFolder ¶
AppendToFolder appends a message to a server folder (e.g. Sent).
func (*IMAPWorker) Connect ¶
func (w *IMAPWorker) Connect() error
Connect establishes a connection to the IMAP server and authenticates. Also opens a second connection dedicated to body fetches.
func (*IMAPWorker) DeleteMailbox ¶
func (w *IMAPWorker) DeleteMailbox(folder string) error
DeleteMailbox deletes a mailbox on the IMAP server.
func (*IMAPWorker) Disconnect ¶
func (w *IMAPWorker) Disconnect()
Disconnect closes the IMAP connection gracefully if idle, or forcefully if an operation is in flight. This never blocks indefinitely, preventing deadlocks when the network is down and a cmd.Wait() is stuck.
func (*IMAPWorker) FetchBody ¶
func (w *IMAPWorker) FetchBody(folder string, uid uint32) (BodyResult, error)
FetchBody fetches the full body of a specific message by UID.
func (*IMAPWorker) FetchBodyDirect ¶ added in v0.10.0
func (w *IMAPWorker) FetchBodyDirect(folder string, uid uint32) (BodyResult, error)
FetchBodyDirect fetches a message body using the dedicated fetch connection, bypassing the main opMu so it doesn't block behind sync operations. Falls back to the main connection if the fetch client is unavailable. If a newer fetch has been requested (wantedFetchUID changed), this fetch returns early to avoid blocking the one the user actually wants.
func (*IMAPWorker) FetchRawMessage ¶
func (w *IMAPWorker) FetchRawMessage(folder string, uid uint32) ([]byte, error)
FetchRawMessage fetches the full RFC 5322 message bytes for a UID.
func (*IMAPWorker) FolderStatus ¶
func (w *IMAPWorker) FolderStatus(folder string) (uidNext uint32, uidValidity uint32, err error)
FolderStatus returns UIDNEXT and UIDVALIDITY for a folder via STATUS (no SELECT needed).
func (*IMAPWorker) Idle ¶
Idle starts IMAP IDLE on the given folder and blocks until new mail arrives or the timeout is reached. Returns true if new mail arrived.
func (*IMAPWorker) IsConnected ¶
func (w *IMAPWorker) IsConnected() bool
IsConnected returns true if the IMAP client exists.
func (*IMAPWorker) ListMailboxes ¶
func (w *IMAPWorker) ListMailboxes() ([]string, error)
ListMailboxes fetches the list of mailboxes and syncs them to the cache.
func (*IMAPWorker) MarkRead ¶
func (w *IMAPWorker) MarkRead(folder string, uid uint32) error
MarkRead sets the \Seen flag on a message by UID.
func (*IMAPWorker) MarkReadBatch ¶ added in v0.7.0
func (w *IMAPWorker) MarkReadBatch(folder string, uids []uint32) error
MarkReadBatch marks multiple messages as read in a single IMAP operation.
func (*IMAPWorker) MoveToFolder ¶ added in v0.9.0
func (w *IMAPWorker) MoveToFolder(srcFolder string, uid uint32, dstFolder string) error
MoveToFolder moves a message from one folder to another via IMAP (COPY + STORE \Deleted + EXPUNGE).
func (*IMAPWorker) MoveToFolderBatch ¶ added in v0.9.0
func (w *IMAPWorker) MoveToFolderBatch(srcFolder string, uids []uint32, dstFolder string) error
MoveToFolderBatch moves multiple messages from one folder to another via IMAP.
func (*IMAPWorker) MoveToTrash ¶
func (w *IMAPWorker) MoveToTrash(folder string, uid uint32) error
MoveToTrash moves a message to the Trash folder via IMAP (COPY + STORE \Deleted + EXPUNGE).
func (*IMAPWorker) MoveToTrashBatch ¶
func (w *IMAPWorker) MoveToTrashBatch(folder string, uids []uint32, onProgress func(done, total int)) error
MoveToTrashBatch moves multiple messages to the Trash folder via IMAP. Processes UIDs in chunks to avoid server-side limits and timeouts. If onProgress is non-nil, it is called after each chunk with (done, total).
func (*IMAPWorker) Ping ¶ added in v0.10.4
func (w *IMAPWorker) Ping() bool
Ping checks if the IMAP connection is alive by issuing a NOOP command. Returns true if the connection is healthy.
func (*IMAPWorker) SetWantedFetchUID ¶ added in v0.10.1
func (w *IMAPWorker) SetWantedFetchUID(uid uint32)
SetWantedFetchUID records which UID the user currently wants fetched. Stale fetches (for a different UID) will skip after acquiring the lock.
func (*IMAPWorker) SyncFolder ¶
func (w *IMAPWorker) SyncFolder(folder string, onProgress ...func(fetched int)) (int, error)
SyncFolder syncs a single folder via IMAP FETCH. If onProgress is non-nil, it is called periodically with the number of new messages fetched so far.
type NewMailMsg ¶
NewMailMsg signals that new mail arrived via IDLE.
type RestoreResult ¶ added in v0.9.0
RestoreResult is the result of restoring messages from Trash via IMAP.
type SMTPWorker ¶
type SMTPWorker struct {
// contains filtered or unexported fields
}
SMTPWorker handles sending email via SMTP.
func NewSMTPWorker ¶
func NewSMTPWorker(acct config.AccountConfig, creds *auth.Credentials) *SMTPWorker
NewSMTPWorker creates a new SMTP worker.
func (*SMTPWorker) Send ¶
func (w *SMTPWorker) Send(req SendRequest) (string, []byte, error)
Send sends an email and returns the message ID and the raw message bytes (for IMAP APPEND to Sent folder).
type SendRequest ¶
SendRequest is a request to send an email via SMTP.
type SendResult ¶
SendResult is the result of sending an email.
type SyncAccountCompleteMsg ¶
SyncAccountCompleteMsg signals that a single account finished syncing.
type SyncAllCompleteMsg ¶
type SyncAllCompleteMsg struct {
Errors []error
}
SyncAllCompleteMsg signals that initial sync of all accounts is done.
type SyncProgressMsg ¶
type SyncProgressMsg struct {
Account string
Folder string
Done int // folders completed so far
Total int // total folders
Messages int // messages fetched in current folder (0 = just started)
}
SyncProgressMsg reports per-folder progress during account sync.
type SyncRequest ¶
SyncRequest requests syncing a specific folder.