Lightr
Lightweight Email Server
2026
Solo Developer
A lightweight, self-hosted email server written in Go. SMTP inbound/outbound, IMAP, REST API, DKIM signing, and multi-domain support β all in a single binary backed by SQLite.
Lightr
A lightweight, self-hosted email server written in Go. Single binary, multi-domain, full-stack email.
The Problem
Self-hosting email is notoriously painful. Existing solutions like Postfix + Dovecot require stitching together multiple daemons, writing cryptic config files, and constantly fighting deliverability issues. Managed email is expensive at scale, and privacy-conscious users or small teams often have no middle ground between Gmail and a week-long sysadmin headache.
The Solution
Lightr is a complete email server in a single Go binary. It handles SMTP (inbound and outbound), IMAP (for email clients), and exposes a REST API for programmatic management. Everything runs off SQLite β no external database required.
How It Works
- SMTP Receiver β Accepts inbound email, parses MIME structures, and stores messages in per-account mailboxes
- SMTP Relay β Sends outbound email with automatic DKIM signing for deliverability
- IMAP Server β Lets standard email clients (Thunderbird, Apple Mail, etc.) connect and manage mailboxes
- REST API β Create organizations, domains, accounts, and templates programmatically
- Email Queue β Persistent queue with exponential backoff for failed deliveries
Key Features
- Single Binary β Download, configure, run. No runtime dependencies
- Multi-Domain β Host email for multiple domains with per-domain TLS via SNI
- DKIM Signing β Built-in key generation and automatic outbound signing
- IMAP Access β Full IMAP server for standard email clients
- REST API β Complete HTTP API for domain, account, and template management
- Email Queue β Persistent outbound queue with retry and backoff
- Open/Click Tracking β Pixel tracking for opens, redirect tracking for clicks
- Webhooks β Notify external services on email events (delivery, bounce, open)
- Bounce Handling β Automatic bounce processing and feedback loops
- Rate Limiting β Configurable rate limits per account and domain
- TLS Everywhere β HTTPS, SMTP STARTTLS, and IMAPS with Let's Encrypt support
- SQLite Storage β Zero-dependency, file-based storage with blob attachments
- Multi-Tenant β Organization-level isolation for SaaS or agency use
- Systemd & Docker β Runs as a service or in a container
Technical Stack
- Go 1.24 β Single-binary builds for any platform
- go-smtp β SMTP protocol implementation (emersion/go-smtp)
- go-imap v2 β IMAP server implementation (emersion/go-imap)
- go-msgauth β DKIM signing and verification
- SQLite β Embedded database via modernc.org/sqlite (pure Go, no CGo)
- Cobra β CLI framework
- YAML β Human-readable configuration
Usage
# Install via quickstart
curl -fsSL https://raw.githubusercontent.com/nigelbasa/lightr/main/quickstart.sh | sudo bash
# Or build from source
go build -o lightr ./cmd/lightr
# Initialize (creates config, generates API key)
lightr init
# Create an organization and domain
lightr add-org --name "My Company"
lightr add-domain --org <id> --name mail.example.com
# Generate DKIM keys (outputs DNS TXT record to add)
lightr dkim-gen --domain mail.example.com
# Create an email account
lightr add-account --domain <id> --email user@mail.example.com
# Start the server
lightr serve
# lightr.yaml β minimal config
data_dir: ./data
http:
addr: ":8080"
smtp:
addr: ":2525"
domain: "mail.yourdomain.com"
imap:
addr: ":1143"
dkim:
selector: "default"
key_bits: 2048
Architecture
Lightr's internal structure follows a clean domain-driven design with 37 packages covering the full email lifecycle:
- smtp/ β SMTP server, relay, and DKIM signing
- imap/ β IMAP server implementation
- api/ β REST API handlers
- queue/ β Persistent email queue with retries
- storage/ β SQLite database and blob storage
- tracking/ β Open/click tracking
- webhook/ β Event notification system
- bounce/ β Bounce processing and feedback loops
- filter/ β Email filtering rules
- ratelimit/ β Per-account and per-domain rate limiting
- security/ β TLS, authentication, and encryption
Why I Built This
I needed email infrastructure for my own projects β transactional emails for Inzwi, school communications for Nyanhewe, and personal email. Running Postfix + Dovecot felt like maintaining a legacy system. I wanted something I could understand end-to-end, configure in one YAML file, and deploy as a single binary. Lightr is that server.
Links
Built With
Want to see more?
View All Projects