9biff
IMAP-to-9P notification bridge. Monitor an IMAP mailbox and write new
message notifications to 9P file endpoints.
Quick Start
go build ./cmd/9biff
cp config.example.yaml config.yaml
# Edit config.yaml with your IMAP credentials and 9P endpoints
./9biff -config config.yaml
Configuration
9biff supports YAML, JSON, and TOML configuration files. Format is
auto-detected from the file extension.
| Field |
Type |
Required |
Default |
Description |
imap.host |
string |
yes |
— |
IMAP server hostname |
imap.port |
int |
yes |
993 |
IMAP server port |
imap.tls |
string |
yes |
tls |
TLS mode: tls, starttls, none |
imap.username |
string |
yes |
— |
IMAP login username |
imap.password |
string |
yes |
— |
IMAP login password |
mailbox |
string |
no |
INBOX |
Mailbox to monitor |
interval |
duration |
no |
60s |
Poll interval |
template |
string |
no |
{{.FromName}} <{{.From}}> - {{.Subject}} |
Global default template |
endpoints |
array |
yes |
— |
List of 9P endpoints |
batch.enabled |
bool |
no |
false |
Enable message batching |
batch.size |
int |
no |
10 |
Max messages per batch |
batch.timeout |
duration |
no |
5s |
Max wait before flushing batch |
Endpoint Fields
| Field |
Type |
Required |
Default |
Description |
url |
string |
yes |
— |
9P server URL (tcp://host:port or unix:///path) |
template |
string |
no |
— |
Per-endpoint template override |
file_path |
string |
no |
/ |
File path within 9P filesystem |
timeout |
duration |
no |
30s |
Connection timeout |
overwrite |
bool |
no |
false |
Overwrite file instead of appending |
Environment Variable Overrides
All config values can be overridden via environment variables:
| Variable |
Config Field |
9BIFF_IMAP_HOST |
imap.host |
9BIFF_IMAP_PORT |
imap.port |
9BIFF_IMAP_TLS |
imap.tls |
9BIFF_IMAP_USERNAME |
imap.username |
9BIFF_IMAP_PASSWORD |
imap.password |
9BIFF_MAILBOX |
mailbox |
9BIFF_INTERVAL |
interval |
9BIFF_TEMPLATE |
template |
Template Syntax
Notifications are rendered using Go's text/template syntax. Available
template fields:
| Field |
Type |
Description |
.From |
string |
Sender email address |
.FromName |
string |
Sender display name |
.Subject |
string |
Email subject |
.Timestamp |
time.Time |
Message date/time |
.MessageID |
string |
Unique message identifier |
.Snippet |
string |
First 200 characters of body |
.Body |
string |
Full plain text body |
Template Functions
| Function |
Description |
Example |
truncate N |
Truncate to N chars |
{{truncate 50 .Subject}} |
timefmt "layout" |
Format timestamp |
{{timefmt "15:04" .Timestamp}} |
upper |
Uppercase |
{{upper .Subject}} |
lower |
Lowercase |
{{lower .From}} |
Template Examples
# Default
{{.FromName}} <{{.From}}> - {{.Subject}}
# With timestamp
[{{timefmt "2006-01-02 15:04:05" .Timestamp}}] {{.From}} - {{.Subject}}
# Full detail
From: {{.FromName}} <{{.From}}>
Subject: {{.Subject}}
Date: {{timefmt "2006-01-02 15:04:05" .Timestamp}}
{{truncate 100 .Snippet}}
# Just subject
{{.Subject}}
Command-Line Flags
| Flag |
Description |
-config <path> |
Path to configuration file (default: config.yaml) |
-version |
Display version and exit |
License
MIT