mail

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2024 License: BSD-3-Clause Imports: 38 Imported by: 0

Documentation

Overview

Package mail implements a GUI email client.

Index

Constants

This section is empty.

Variables

View Source
var Settings = &SettingsData{
	SettingsBase: core.SettingsBase{
		Name: "Mail",
		File: filepath.Join(core.TheApp.DataDir(), "Cogent Mail", "settings.toml"),
	},
}

Settings is the currently active global Cogent Mail settings instance.

Functions

func FilenameBase32

func FilenameBase32(s string) string

FilenameBase32 converts the given string to a filename-safe base32 version.

func IMAPToMailAddresses

func IMAPToMailAddresses(as []imap.Address) []*mail.Address

IMAPToMailAddresses converts the given [imap.Address]es to [mail.Address]es.

Types

type AddressTextField

type AddressTextField struct {
	core.TextField
	Address mail.Address
}

AddressTextField represents a mail.Address with a core.TextField.

func NewAddressTextField

func NewAddressTextField(parent ...tree.Node) *AddressTextField

NewAddressTextField returns a new AddressTextField with the given optional parent: AddressTextField represents a mail.Address with a core.TextField.

func (*AddressTextField) Init added in v0.1.0

func (at *AddressTextField) Init()

func (*AddressTextField) WidgetValue added in v0.1.0

func (at *AddressTextField) WidgetValue() any

type App

type App struct {
	core.Frame

	// AuthToken contains the [oauth2.Token] for each account.
	AuthToken map[string]*oauth2.Token `set:"-"`

	// AuthClient contains the [sasl.Client] authentication for sending messages for each account.
	AuthClient map[string]sasl.Client `set:"-"`

	// IMAPCLient contains the imap clients for each account.
	IMAPClient map[string]*imapclient.Client `set:"-"`

	// ComposeMessage is the current message we are editing
	ComposeMessage *SendMessage `set:"-"`

	// Cache contains the cache data, keyed by account and then mailbox.
	Cache map[string]map[string][]*CacheData `set:"-"`

	// ReadMessage is the current message we are reading
	ReadMessage *CacheData `set:"-"`

	// The current email account
	CurrentEmail string `set:"-"`

	// The current mailbox
	CurrentMailbox string `set:"-"`
}

App is an email client app.

func NewApp

func NewApp(parent ...tree.Node) *App

NewApp returns a new App with the given optional parent: App is an email client app.

func (*App) Auth

func (a *App) Auth() error

Auth authorizes access to the user's mail and sets [App.AuthClient]. If the user does not already have a saved auth token, it calls [SignIn].

func (*App) CacheMessages

func (a *App) CacheMessages() error

CacheMessages caches all of the messages from the server that have not already been cached. It caches them in the app's data directory.

func (*App) CacheMessagesForAccount

func (a *App) CacheMessagesForAccount(email string) error

CacheMessages caches all of the messages from the server that have not already been cached for the given email account. It caches them in the app's data directory.

func (*App) CacheMessagesForMailbox

func (a *App) CacheMessagesForMailbox(c *imapclient.Client, email string, mailbox string) error

CacheMessagesForMailbox caches all of the messages from the server that have not already been cached for the given email account and mailbox. It caches them in the app's data directory.

func (*App) CacheUIDs

func (a *App) CacheUIDs(uids []imap.UID, c *imapclient.Client, email string, mailbox string, dir string, cached []*CacheData, cachedFile string) error

CacheUIDs caches the messages with the given UIDs in the context of the other given values, using an iterative batched approach that fetches the five next most recent messages at a time, allowing for concurrent mail modifiation operations and correct ordering.

func (*App) Compose

func (a *App) Compose()

Compose pulls up a dialog to send a new message

func (*App) GetMail

func (a *App) GetMail() error

func (*App) Init

func (a *App) Init()

func (*App) MakeToolbar

func (a *App) MakeToolbar(p *tree.Plan)

func (*App) MoveMessage

func (a *App) MoveMessage(mailbox string) error

MoveMessage moves the current message to the given mailbox.

func (*App) SendMessage

func (a *App) SendMessage() error

SendMessage sends the current message

func (*App) SignIn

func (a *App) SignIn() (string, error)

SignIn displays a dialog for the user to sign in with the platform of their choice. It returns the user's email address.

func (*App) UpdateMessageList

func (a *App) UpdateMessageList()

UpdateMessageList updates the message list from [App.Cache].

func (*App) UpdateReadMessage

func (a *App) UpdateReadMessage() error

UpdateReadMessage updates the view of the message currently being read.

type CacheData

type CacheData struct {
	imap.Envelope
	UID      imap.UID
	Filename string
}

CacheData contains the data stored for a cached message in the cached messages file. It contains basic information about the message so that it can be displayed in the mail list in the GUI.

func (*CacheData) ToMessage

func (cd *CacheData) ToMessage() *ReadMessage

ToMessage converts the CacheData to a ReadMessage.

type ReadMessage

type ReadMessage struct {
	From    []*mail.Address `display:"inline"`
	To      []*mail.Address `display:"inline"`
	Subject string
	Date    time.Time
}

ReadMessage represents the data necessary to display a message for the user to read.

type SendMessage

type SendMessage struct {
	From    []*mail.Address `display:"inline"`
	To      []*mail.Address `display:"inline"`
	Subject string
	Body    string `display:"-"`
}

SendMessage represents the data necessary for the user to send a message.

type SettingsData

type SettingsData struct {
	core.SettingsBase

	// Accounts are the email accounts the user is signed into.
	Accounts []string
}

SettingsData is the data type for the global Cogent Mail settings.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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