importer

package
v0.167.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 25 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 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.

Rule 4 (all data stays on the machine): it only ever reads local files that already belong to the user. Passwords it decrypts never leave the process — they are not placed in any value that is serialized to HTTP (see Source, whose credentials map is unexported). The caller passes them straight to the IMAP/SMTP servers the user chose, never anywhere else.

Outlook for Mac is not read. Its profile lives in another app's group container (~/Library/Group Containers/UBF8T346G9.Office/Outlook), which macOS 14 and later guard with the "access data from other apps" prompt, an OS dialog Caprock does not raise; the new Outlook keeps its accounts in Microsoft's cloud sync rather than in a file; and what it holds is mostly Exchange and Microsoft 365, which Sign in with Microsoft adds by address.

Index

Constants

View Source
const FullDiskAccessHelp = "" /* 131-byte string literal not displayed */

FullDiskAccessHelp is what the import screen says when Apple Mail's account list cannot be read. macOS guards ~/Library/Accounts with Full Disk Access, which a launchd daemon does not have until the user ticks it, and the open fails with EPERM; no prompt is ever shown, so without these words the source looked empty (owner, 2026-10-22: his iCloud account was not listed).

Variables

This section is empty.

Functions

func ProviderFor added in v0.117.2

func ProviderFor(email, imapHost string) string

ProviderFor names the mail service behind an address and its IMAP server, for the one sign-in it needs: "google" and "microsoft" (OAuth, or an app password), "icloud", "yahoo" and "fastmail" (an app password), or "" for any other server (its own password).

Types

type Account

type Account struct {
	Name        string `json:"name"`
	Email       string `json:"email"`
	Username    string `json:"username"`
	IMAPHost    string `json:"imap_host"`
	IMAPPort    int    `json:"imap_port"`
	IMAPTLS     string `json:"imap_tls"` // tls | starttls | none
	SMTPHost    string `json:"smtp_host"`
	SMTPPort    int    `json:"smtp_port"`
	SMTPTLS     string `json:"smtp_tls"`
	HasPassword bool   `json:"has_password"`
	// Provider is ProviderFor's answer: google | microsoft | icloud | yahoo |
	// fastmail, or "" for any other server.
	Provider string `json:"provider,omitempty"`
	// LastUsed is when the mail app last wrote the profile this account came
	// from (unix ms; Thunderbird's prefs.js, Apple's account store), so the
	// screen can say where it was found and leave stale ones unticked.
	LastUsed int64 `json:"last_used,omitempty"`
}

Account is one importable mailbox. It never carries a password: the decrypted password, when there is one, is held in Source.creds and reached only in-process through Source.Password.

type Found added in v0.117.2

type Found struct {
	Account
	// Source is the Kind to import it from: the one that holds its password
	// when any does, else the first that listed it.
	Source string `json:"source"`
	// From lists every mail app that has it, in scan order.
	From []string `json:"from"`
}

Found is one account to offer on the "Import everything" screen: the same address seen in several mail apps is listed once.

func Merge added in v0.117.2

func Merge(sources []Source) []Found

Merge lists every account of every source once, keyed by address (case does not matter), in the order the sources and their accounts came. When two apps have the same address the one with a saved password wins, so the user is asked for nothing that is already on the machine.

type Source

type Source struct {
	Kind     string    `json:"kind"`  // thunderbird | apple_mail
	Label    string    `json:"label"` // "Thunderbird", "Apple Mail"
	Accounts []Account `json:"accounts"`
	// NeedsPermission names an OS permission Caprock must be granted before it
	// can read this source at all (e.g. "full_disk_access" for Apple Mail).
	NeedsPermission string `json:"needs_permission,omitempty"`
	// Program is the file to allow in Full Disk Access when NeedsPermission is
	// set: the daemon's own executable, which is what macOS checks. The HTTP
	// handler fills it; the importer does not know which binary it runs in.
	Program string `json:"program,omitempty"`
	// Error is a human-readable reason this source could not be fully read.
	Error string `json:"error,omitempty"`
	// LastUsed is the newest LastUsed of its accounts (unix ms).
	LastUsed int64 `json:"last_used,omitempty"`
	// contains filtered or unexported fields
}

Source is one other mail client found on the machine.

func Sources

func Sources(home string) []Source

Sources lists the importable mail clients under home. It reads local files only and opens nothing else. A client that is absent yields no Source; a client that is present but unreadable yields a Source carrying Error or NeedsPermission so the dashboard can explain what to do.

func (Source) Password

func (s Source) Password(email string) (string, bool)

Password returns the decrypted password for email, if one was recovered. It is only callable in-process; it is never serialized.

Jump to

Keyboard shortcuts

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