2026-07-20 15:14:52 +00:00
# mbrts
2026-07-20 16:14:19 +00:00
Real-time mail delivery for maildirs via Fastmail's JMAP push API.
2026-07-20 15:14:52 +00:00
2026-07-20 16:14:19 +00:00
Connects to Fastmail's JMAP EventSource stream and delivers new messages directly to a local Maildir the moment they arrive without polling.
2026-07-20 15:14:52 +00:00
## How it works
2026-07-20 16:49:43 +00:00
On first run, or when the saved JMAP state is stale, mbrts falls back to `mbsync` for a full sync, then takes over from that point.
2026-07-20 15:14:52 +00:00
## Setup
Create a Fastmail API token at **Settings → Security → API Tokens** .
2026-07-20 16:14:19 +00:00
### Config file
By default mbrts reads `$XDG_CONFIG_HOME/mbrts/config.yaml` (e.g. `~/.config/mbrts/config.yaml` ):
```yaml
accounts:
- name: Personal
maildir_path: /home/you/.mail/Personal
password_command: "pass show fastmail/api-token"
```
Each account requires exactly one token source:
| Field | Description |
|---|---|
| `password_command` | Shell command that prints the token to stdout |
| `token_file` | Path to a file containing the token |
| `token_env` | Name of an environment variable containing the token |
Optional fields: `mbsync_account` (mbsync channel/group name; defaults to `name` ), `log_level` (top-level: `debug` , `info` , `warn` , `error` ).
### CLI flags
Every config file option has an equivalent flag. Flags override the config file. A single account can be configured entirely on the command line without a config file:
2026-07-20 15:14:52 +00:00
```
2026-07-20 16:14:19 +00:00
mbrts --name Personal \
--maildir-path ~/.mail/Personal \
--password-command "pass show fastmail/api-token"
2026-07-20 15:14:52 +00:00
```
2026-07-20 16:14:19 +00:00
Run `mbrts --help` for the full flag list, or `mbrts --version` to print the version.
2026-07-20 16:49:43 +00:00
### Nix
Add mbrts as a flake input:
```nix
inputs.mbrts = {
url = "git+https://code.adriano.fyi/me/mbrts";
inputs.nixpkgs.follows = "nixpkgs";
};
```
The flake exposes:
| Output | Description |
|---|---|
| `packages.*.default` | The `mbrts` binary |
| `overlays.default` | Adds `pkgs.mbrts` |
| `homeManagerModules.default` | The `services.mbrts` home-manager module |
### home-manager module
Add the overlay and module to your home-manager configuration, then configure the service:
```nix
# in your flake outputs
overlays = [ inputs.mbrts.overlays.default ];
# in your home-manager module list
inputs.mbrts.homeManagerModules.default
# in your home-manager config
services.mbrts = {
enable = true;
accounts = [
{
name = "Personal";
maildirPath = "/home/you/.mail/Personal";
passwordCommand = "pass show fastmail/api-token";
}
];
};
```
The module generates a config file and runs mbrts as a `systemd` user service. Logs are available via `journalctl --user -u mbrts -f` .
Module options:
| Option | Type | Default | Description |
|---|---|---|---|
| `enable` | bool | — | Enable the service |
| `package` | package | `pkgs.mbrts` | Package to use |
| `logLevel` | enum | `"info"` | `debug` , `info` , `warn` , or `error` |
| `accounts` | list | `[]` | List of account submodules (see config file fields above) |
2026-07-20 16:14:19 +00:00
## Build
```
CGO_ENABLED=0 go build -o mbrts .
```
## aerc
Configure the account source as `maildir://` so aerc picks up delivered messages immediately via inotify:
```ini
source = maildir:///home/you/.mail/Personal
```