config

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddContact added in v0.8.0

func AddContact(name, email string) error

AddContact adds or updates a contact in the cache.

func ClearEmailCache added in v0.8.0

func ClearEmailCache() error

ClearEmailCache removes the cache file.

func DeleteDraft added in v0.8.0

func DeleteDraft(id string) error

DeleteDraft removes a draft by ID.

func HasDrafts added in v0.8.0

func HasDrafts() bool

HasDrafts checks if there are any saved drafts.

func HasEmailCache added in v0.8.0

func HasEmailCache() bool

HasEmailCache checks if a cache file exists.

func HasSignature added in v0.15.0

func HasSignature() bool

HasSignature checks if a signature file exists and is non-empty.

func LoadSignature added in v0.15.0

func LoadSignature() (string, error)

LoadSignature loads the signature from the signature file.

func SaveConfig

func SaveConfig(config *Config) error

SaveConfig saves the given configuration to the config file.

func SaveContactsCache added in v0.8.0

func SaveContactsCache(cache *ContactsCache) error

SaveContactsCache saves contacts to the cache file.

func SaveDraft added in v0.8.0

func SaveDraft(draft Draft) error

SaveDraft saves or updates a draft.

func SaveDraftsCache added in v0.8.0

func SaveDraftsCache(cache *DraftsCache) error

SaveDraftsCache saves drafts to the cache file.

func SaveEmailCache added in v0.8.0

func SaveEmailCache(cache *EmailCache) error

SaveEmailCache saves emails to the cache file.

func SaveSignature added in v0.15.0

func SaveSignature(signature string) error

SaveSignature saves the signature to the signature file.

Types

type Account added in v0.8.0

type Account struct {
	ID              string `json:"id"`
	Name            string `json:"name"`
	Email           string `json:"email"`
	Password        string `json:"password"`
	ServiceProvider string `json:"service_provider"` // "gmail", "icloud", or "custom"
	// FetchEmail is the single email address for which messages should be fetched.
	// If empty, it will default to `Email` when accounts are added.
	FetchEmail string `json:"fetch_email,omitempty"`

	// Custom server settings (used when ServiceProvider is "custom")
	IMAPServer string `json:"imap_server,omitempty"`
	IMAPPort   int    `json:"imap_port,omitempty"`
	SMTPServer string `json:"smtp_server,omitempty"`
	SMTPPort   int    `json:"smtp_port,omitempty"`
}

Account stores the configuration for a single email account.

func (*Account) GetIMAPPort added in v0.8.0

func (a *Account) GetIMAPPort() int

GetIMAPPort returns the IMAP port for the account.

func (*Account) GetIMAPServer added in v0.8.0

func (a *Account) GetIMAPServer() string

GetIMAPServer returns the IMAP server address for the account.

func (*Account) GetSMTPPort added in v0.8.0

func (a *Account) GetSMTPPort() int

GetSMTPPort returns the SMTP port for the account.

func (*Account) GetSMTPServer added in v0.8.0

func (a *Account) GetSMTPServer() string

GetSMTPServer returns the SMTP server address for the account.

type CachedEmail added in v0.8.0

type CachedEmail struct {
	UID       uint32    `json:"uid"`
	From      string    `json:"from"`
	To        []string  `json:"to"`
	Subject   string    `json:"subject"`
	Date      time.Time `json:"date"`
	MessageID string    `json:"message_id"`
	AccountID string    `json:"account_id"`
}

CachedEmail stores essential email data for caching.

type Config

type Config struct {
	Accounts []Account `json:"accounts"`
}

Config stores the user's email configuration with multiple accounts.

func LoadConfig

func LoadConfig() (*Config, error)

LoadConfig loads the configuration from the config file.

func (*Config) AddAccount added in v0.8.0

func (c *Config) AddAccount(account Account)

AddAccount adds a new account to the configuration.

func (*Config) GetAccountByEmail added in v0.8.0

func (c *Config) GetAccountByEmail(email string) *Account

GetAccountByEmail returns an account by its email address.

func (*Config) GetAccountByID added in v0.8.0

func (c *Config) GetAccountByID(id string) *Account

GetAccountByID returns an account by its ID.

func (*Config) GetFirstAccount added in v0.8.0

func (c *Config) GetFirstAccount() *Account

GetFirstAccount returns the first account or nil if none exist.

func (*Config) HasAccounts added in v0.8.0

func (c *Config) HasAccounts() bool

HasAccounts returns true if there are any configured accounts.

func (*Config) RemoveAccount added in v0.8.0

func (c *Config) RemoveAccount(id string) bool

RemoveAccount removes an account by its ID.

type Contact added in v0.8.0

type Contact struct {
	Name     string    `json:"name"`
	Email    string    `json:"email"`
	LastUsed time.Time `json:"last_used"`
	UseCount int       `json:"use_count"`
}

Contact stores a contact's name and email address.

func SearchContacts added in v0.8.0

func SearchContacts(query string) []Contact

SearchContacts searches for contacts matching the query.

type ContactsCache added in v0.8.0

type ContactsCache struct {
	Contacts  []Contact `json:"contacts"`
	UpdatedAt time.Time `json:"updated_at"`
}

ContactsCache stores all known contacts.

func LoadContactsCache added in v0.8.0

func LoadContactsCache() (*ContactsCache, error)

LoadContactsCache loads contacts from the cache file.

type Draft added in v0.8.0

type Draft struct {
	ID             string    `json:"id"`
	To             string    `json:"to"`
	Cc             string    `json:"cc,omitempty"`
	Bcc            string    `json:"bcc,omitempty"`
	Subject        string    `json:"subject"`
	Body           string    `json:"body"`
	AttachmentPath string    `json:"attachment_path,omitempty"`
	AccountID      string    `json:"account_id"`
	InReplyTo      string    `json:"in_reply_to,omitempty"`
	References     []string  `json:"references,omitempty"`
	QuotedText     string    `json:"quoted_text,omitempty"`
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`
}

Draft stores a saved email draft.

func GetAllDrafts added in v0.8.0

func GetAllDrafts() []Draft

GetAllDrafts retrieves all drafts sorted by update time (newest first).

func GetDraft added in v0.8.0

func GetDraft(id string) *Draft

GetDraft retrieves a draft by ID.

type DraftsCache added in v0.8.0

type DraftsCache struct {
	Drafts    []Draft   `json:"drafts"`
	UpdatedAt time.Time `json:"updated_at"`
}

DraftsCache stores all saved drafts.

func LoadDraftsCache added in v0.8.0

func LoadDraftsCache() (*DraftsCache, error)

LoadDraftsCache loads drafts from the cache file.

type EmailCache added in v0.8.0

type EmailCache struct {
	Emails    []CachedEmail `json:"emails"`
	UpdatedAt time.Time     `json:"updated_at"`
}

EmailCache stores cached emails for all accounts.

func LoadEmailCache added in v0.8.0

func LoadEmailCache() (*EmailCache, error)

LoadEmailCache loads emails from the cache file.

Jump to

Keyboard shortcuts

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