mail

package
v0.117.2 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 26 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mail is Caprock Mail: an IMAP/SMTP client that keeps every inbox the user adds in one local database (mail.db, beside Caprock's own) and serves it to the dashboard under /v1/mail.

It is an integration the user switches on by adding an account (ADR-047): until then nothing is opened, no goroutine runs and nothing leaves the machine. Once an account exists, Caprock talks only to the IMAP and SMTP servers the user typed in (for an account signed in with Google or Microsoft: that provider's servers and token endpoint, internal/mail/oauth), and — when local AI is turned on — to the model server at the address in Mail's settings (loopback by default).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

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

Service owns Mail's database and sync engine, both opened on first use.

Sample mode (POST /v1/mail/sample, or CAPROCK_MAIL_DEMO=1 for the whole run) puts a second, throwaway instance in front of the real one: two sample accounts on in-process fake servers, a temporary database and passwords kept in memory. While it is on every route serves the sample; the real mail.db and the keychain are not touched, and turning it off drops the sample and leaves the real instance as it was (or still unopened).

func New

func New(dataDir string, log *slog.Logger) *Service

New prepares Mail under dataDir. If Mail was used before (mail.db exists) its accounts start syncing at once; otherwise nothing happens until the dashboard asks.

CAPROCK_MAIL_DEMO=1 starts in sample mode and keeps it on, for screenshots; the real mail.db is then never opened.

func (*Service) Close

func (s *Service) Close()

Close stops syncing and closes the database (and the sample, if on).

func (*Service) Handler

func (s *Service) Handler() http.Handler

Handler serves /v1/mail/*. Caprock's router puts it behind the same CSRF guard and device pairing as every other /v1 route.

func (*Service) SetSample added in v0.116.0

func (s *Service) SetSample(on bool) error

SetSample turns sample mode on or off. Under CAPROCK_MAIL_DEMO=1 it cannot be turned off.

Directories

Path Synopsis
Package ai talks to a local model through the OpenAI-compatible API that Ollama, LM Studio and llama.cpp all serve.
Package ai talks to a local model through the OpenAI-compatible API that Ollama, LM Studio and llama.cpp all serve.
Package engine talks to mail servers: it keeps the local copy in step with IMAP, applies the user's actions there, and sends over SMTP.
Package engine talks to mail servers: it keeps the local copy in step with IMAP, applies the user's actions there, and sends over SMTP.
Package fakemail runs an in-memory IMAP and SMTP server on loopback, for tests and for the demo mode that previews the client without a real account.
Package fakemail runs an in-memory IMAP and SMTP server on loopback, for tests and for the demo mode that previews the client without a real account.
Package importer reads the mail accounts a user already has in another client — Thunderbird and (on macOS) Apple Mail — so Caprock Mail can offer to add them instead of making the user retype servers and passwords.
Package importer reads the mail accounts a user already has in another client — Thunderbird and (on macOS) Apple Mail — so Caprock Mail can offer to add them instead of making the user retype servers and passwords.
Package store owns the SQLite database.
Package store owns the SQLite database.
Package oauth signs Caprock Mail into Google and Microsoft accounts the way an installed app should (RFC 8252): the authorization code flow with PKCE (RFC 7636, S256) in the user's own browser, redirected back to the daemon on loopback.
Package oauth signs Caprock Mail into Google and Microsoft accounts the way an installed app should (RFC 8252): the authorization code flow with PKCE (RFC 7636, S256) in the user's own browser, redirected back to the daemon on loopback.
oauthtest
Package oauthtest is a fake OAuth provider for tests: an authorization step that stands in for the user's browser, and a token endpoint that checks PKCE, issues ID tokens and refreshes.
Package oauthtest is a fake OAuth provider for tests: an authorization step that stands in for the user's browser, and a token endpoint that checks PKCE, issues ID tokens and refreshes.
Package providers knows the server settings of common mail hosts, so adding an account is an address and a password.
Package providers knows the server settings of common mail hosts, so adding an account is an address and a password.
Package secrets keeps account passwords out of the database: in the OS keychain (macOS login keychain, Windows Credential Manager, Secret Service), else a file only this user can read.
Package secrets keeps account passwords out of the database: in the OS keychain (macOS login keychain, Windows Credential Manager, Secret Service), else a file only this user can read.

Jump to

Keyboard shortcuts

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