imap

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	Index       int    `json:"index"`
	Filename    string `json:"filename"`
	ContentType string `json:"content_type"`
	Size        int64  `json:"size"`
	Data        []byte `json:"-"`
}

type Client

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

func NewClient

func NewClient(cfg *config.Config) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) Connect

func (c *Client) Connect() error

func (*Client) CopyMessages

func (c *Client) CopyMessages(mailbox string, ids []string, destMailbox string) error

CopyMessages copies messages to a destination folder without removing from source. This is used for adding labels in Proton Bridge, where copying to a Labels/X folder adds that label while keeping the message in its original location.

func (*Client) CreateDraft

func (c *Client) CreateDraft(draft *Draft) (uint32, error)

CreateDraft creates a new draft in the Drafts folder

func (*Client) CreateMailbox

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

func (*Client) DeleteDraft

func (c *Client) DeleteDraft(ids []string) error

DeleteDraft deletes a draft (permanently)

func (*Client) DeleteMailbox

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

func (*Client) DeleteMessages

func (c *Client) DeleteMessages(mailbox string, ids []string, permanent bool) error

func (*Client) DownloadAttachment

func (c *Client) DownloadAttachment(mailbox, id string, index int) ([]byte, string, error)

DownloadAttachment downloads a specific attachment by index

func (*Client) GetAttachments

func (c *Client) GetAttachments(mailbox, id string) ([]Attachment, error)

GetAttachments returns a list of attachments for a message without downloading the data

func (*Client) GetDraft

func (c *Client) GetDraft(id string) (*Message, error)

GetDraft retrieves a specific draft

func (*Client) GetMessage

func (c *Client) GetMessage(mailbox string, id string) (*Message, error)

func (*Client) GetMessageLabels

func (c *Client) GetMessageLabels(messageID string) ([]string, error)

GetMessageLabels returns the labels applied to a message by searching label folders. This searches all Labels/* folders for a message with the same Message-ID.

func (*Client) GetThread

func (c *Client) GetThread(mailbox, id string) ([]ThreadMessage, error)

GetThread retrieves all messages in a conversation thread

func (*Client) ListDrafts

func (c *Client) ListDrafts(limit int) ([]MessageSummary, error)

ListDrafts returns drafts from the Drafts folder

func (*Client) ListMailboxes

func (c *Client) ListMailboxes() ([]MailboxInfo, error)

func (*Client) ListMessages

func (c *Client) ListMessages(mailbox string, limit, offset int, unreadOnly bool) ([]MessageSummary, error)

func (*Client) MoveMessage

func (c *Client) MoveMessage(mailbox, id, destMailbox string) error

func (*Client) MoveMessages

func (c *Client) MoveMessages(mailbox string, ids []string, destMailbox string) error

func (*Client) Search

func (c *Client) Search(mailbox string, opts SearchOptions) ([]MessageSummary, error)

func (*Client) SearchIDs

func (c *Client) SearchIDs(mailbox string, opts SearchOptions) ([]string, error)

SearchIDs returns sequence numbers of messages matching the search criteria. This is used for batch operations based on queries.

func (*Client) SelectMailbox

func (c *Client) SelectMailbox(name string) (*MailboxStatus, error)

func (*Client) SetFlags

func (c *Client) SetFlags(mailbox, id string, read, unread, star, unstar bool) error

func (*Client) SetFlagsMultiple

func (c *Client) SetFlagsMultiple(mailbox string, ids []string, read, unread, star, unstar bool) error

func (*Client) UpdateDraft

func (c *Client) UpdateDraft(id string, draft *Draft) (uint32, error)

UpdateDraft updates an existing draft (deletes old, creates new)

type Draft

type Draft struct {
	To      []string
	CC      []string
	Subject string
	Body    string
}

Draft represents an email draft

type MailboxInfo

type MailboxInfo struct {
	Name       string   `json:"name"`
	Delimiter  string   `json:"delimiter"`
	Attributes []string `json:"attributes"`
}

type MailboxStatus

type MailboxStatus struct {
	Name     string `json:"name"`
	Messages uint32 `json:"messages"`
	Recent   uint32 `json:"recent"`
	Unseen   uint32 `json:"unseen"`
}

type Message

type Message struct {
	UID         uint32       `json:"uid"`
	SeqNum      uint32       `json:"seq_num"`
	MessageID   string       `json:"message_id,omitempty"`
	InReplyTo   string       `json:"in_reply_to,omitempty"`
	References  []string     `json:"references,omitempty"`
	From        string       `json:"from"`
	To          []string     `json:"to"`
	CC          []string     `json:"cc,omitempty"`
	Subject     string       `json:"subject"`
	Date        string       `json:"date"`
	DateISO     string       `json:"date_iso,omitempty"`
	Flags       []string     `json:"flags"`
	Labels      []string     `json:"labels,omitempty"`
	TextBody    string       `json:"text_body,omitempty"`
	HTMLBody    string       `json:"html_body,omitempty"`
	RawBody     []byte       `json:"-"`
	Attachments []Attachment `json:"attachments,omitempty"`
}

type MessageSummary

type MessageSummary struct {
	UID     uint32 `json:"uid"`
	SeqNum  uint32 `json:"seq_num"`
	From    string `json:"from"`
	Subject string `json:"subject"`
	Date    string `json:"date"`
	DateISO string `json:"date_iso,omitempty"`
	Seen    bool   `json:"seen"`
	Flagged bool   `json:"flagged"`
}

type SearchOptions

type SearchOptions struct {
	Query          string // General query (searches body text)
	From           string // Filter by sender
	To             string // Filter by recipient
	Subject        string // Filter by subject
	Body           string // Search in message body
	Since          string // Messages since date (YYYY-MM-DD)
	Before         string // Messages before date (YYYY-MM-DD)
	HasAttachments bool   // Only messages with attachments
	LargerThan     int64  // Messages larger than this size in bytes
	SmallerThan    int64  // Messages smaller than this size in bytes
	UseOr          bool   // Combine filters with OR instead of AND
	Negate         bool   // Negate the entire search
}

SearchOptions contains all search criteria for the Search method

type ThreadMessage

type ThreadMessage struct {
	UID       uint32 `json:"uid"`
	SeqNum    uint32 `json:"seq_num"`
	MessageID string `json:"message_id,omitempty"`
	From      string `json:"from"`
	To        string `json:"to"`
	Subject   string `json:"subject"`
	Date      string `json:"date"`
	DateISO   string `json:"date_iso,omitempty"`
	Body      string `json:"body,omitempty"`
	Seen      bool   `json:"seen"`
}

ThreadMessage is a message with body text for thread display

Jump to

Keyboard shortcuts

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