Documentation
¶
Index ¶
- func AddContact(name, email string) error
- func ClearEmailCache() error
- func DeleteDraft(id string) error
- func HasDrafts() bool
- func HasEmailCache() bool
- func SaveConfig(config *Config) error
- func SaveContactsCache(cache *ContactsCache) error
- func SaveDraft(draft Draft) error
- func SaveDraftsCache(cache *DraftsCache) error
- func SaveEmailCache(cache *EmailCache) error
- type Account
- type CachedEmail
- type Config
- type Contact
- type ContactsCache
- type Draft
- type DraftsCache
- type EmailCache
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddContact ¶ added in v0.8.0
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
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 SaveConfig ¶
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 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.
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
GetIMAPPort returns the IMAP port for the account.
func (*Account) GetIMAPServer ¶ added in v0.8.0
GetIMAPServer returns the IMAP server address for the account.
func (*Account) GetSMTPPort ¶ added in v0.8.0
GetSMTPPort returns the SMTP port for the account.
func (*Account) GetSMTPServer ¶ added in v0.8.0
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 ¶
LoadConfig loads the configuration from the config file.
func (*Config) AddAccount ¶ added in v0.8.0
AddAccount adds a new account to the configuration.
func (*Config) GetAccountByEmail ¶ added in v0.8.0
GetAccountByEmail returns an account by its email address.
func (*Config) GetAccountByID ¶ added in v0.8.0
GetAccountByID returns an account by its ID.
func (*Config) GetFirstAccount ¶ added in v0.8.0
GetFirstAccount returns the first account or nil if none exist.
func (*Config) HasAccounts ¶ added in v0.8.0
HasAccounts returns true if there are any configured accounts.
func (*Config) RemoveAccount ¶ added in v0.8.0
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
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"`
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).
type DraftsCache ¶ added in v0.8.0
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.