<!-- Markdown version of https://www.kuzys.com/kuzymail.html, generated from the HTML by tools/make-md.py. Index: https://www.kuzys.com/llms.txt -->

# Mail with *managed attention.*

Mail for agents and the people they work with: notmuch-backed, with IMAP and SMTP underneath, and a managed-attention mode that wakes an agent only when new mail arrives, as a digest rather than a stream of interruptions.

#### At a glance

- **Package**: `kuzymail`
- **Programs**: `kuzymail`, `kuzymaild`
- **Built on**: IMAP, SMTP, Maildir; mbsync, notmuch, msmtp
- **Modes**: managed or manual, per profile
- **License**: AGPL-3.0-or-later

## What it is

kuzymail is the mail layer of the kuzys suite. A daemon, `kuzymaild`, watches the mailbox and decides when an agent should be woken; the `kuzymail` command line handles syncing, searching, reading, replying, archiving and sending. Every command answers in JSON.

Under the hood it orchestrates the tools that already do this well, instead of reimplementing them: `mbsync` for IMAP, `notmuch` for search and threads, `msmtp` for submission, plain Maildir on disk. Nothing about the format is proprietary; you can walk away with your mail at any time.

## Detection is cheap, a turn is not

An agent that polls its own mailbox spends a full turn on every check, and most checks find nothing. kuzymail separates the two. The daemon does the watching, by IMAP IDLE or by a short poll, and wakes the agent only when there is new mail. Messages that arrive together reach the agent as a single digest, and a minimum interval between wake-ups keeps a busy mailbox from becoming a stream of interruptions.

Each profile runs in **managed** mode, where the daemon wakes the agent, or in **manual** mode, where nothing is injected and the profile reads mail when it decides to.

## Attention rules

In managed mode, rules decide when new mail is worth a wake-up: hour windows and weekdays in the profile's own timezone, and matches on subject, sender or message attributes. A profile can sleep through the night and still be woken by a message marked urgent.

```console
# wake during working hours, and at any time for urgent mail
$ kuzymail attention set --profile ada \
    --mode managed --timezone Europe/Rome --detection idle
$ kuzymail attention rule add --profile ada --hours 08:00-20:00
$ kuzymail attention rule add --profile ada --subject "urgent"
```

## Reading and answering

```console
$ kuzymail list --profile ada --account work --query "tag:unread"
$ kuzymail show --profile ada --account work --message-id "<id@example.org>"
$ kuzymail reply --profile ada --account work --message-id "<id@example.org>" \
    --body "Thanks, I'll have it ready by Friday."
```

Replies thread correctly, and archiving or deleting is a dry run until it is confirmed with `--yes`.

## Outbound policy

Agents send mail too, so every send can be checked first: `--dry-run` builds and validates the message without touching SMTP. Each account carries a policy for recipients outside its own domain. External recipients are always reported; an account can require an explicit `--allow-external` for them, or block them outright. Messages can carry an escalation level and structured attributes, so the receiving side can tell a routine note from one that needs a person.

## Profiles and accounts

Each profile holds one or more accounts, with its own state, configuration and secrets. One person can run separate workflows for separate mailboxes, and an agent profile stays isolated from everyone else on the same host.

## Install

### Python / PyPI

Python 3.11 or later, in a virtual environment. pip installs the client and the daemon's program, not its systemd services, and not isync, notmuch and msmtp, which come from the system's package manager.

```console
$ python3 -m venv ~/.venvs/kuzymail
$ . ~/.venvs/kuzymail/bin/activate
$ python -m pip install kuzymail
```

### Debian / APT

On Debian 13 (amd64), with the [kuzys repository](https://www.kuzys.com/install.md) configured, one Debian package ships both the client and the daemon.

```console
$ sudo apt install kuzymail
```

### Fedora / RPM

On Fedora 45 (x86_64), with the [kuzys RPM repository](https://rpm.kuzys.com/) configured, one package ships both the client and the daemon.

```console
$ sudo dnf install kuzymail
```

## Source and documentation

[gitlab.com/kuzys/kuzymail](https://gitlab.com/kuzys/kuzymail). Separate guides for agents and for people ship with the Debian package, under `/usr/share/doc/kuzymail`.
