sendry

module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: GPL-3.0

README

Sendry

MTA (Mail Transfer Agent) server for sending emails.

Русская версия

Features

  • SMTP server (ports 25, 587) with AUTH support
  • SMTPS server (port 465) with implicit TLS
  • STARTTLS support for secure connections
  • Let's Encrypt (ACME) automatic certificate management
  • DKIM signing for outgoing emails
  • HTTP API for sending emails
  • Persistent queue with BoltDB
  • Retry logic with exponential backoff
  • Multi-domain support with different modes:
    • production - normal delivery
    • sandbox - capture emails locally (for testing)
    • redirect - redirect all emails to specified addresses
    • bcc - normal delivery + copy to archive
  • Rate limiting (per domain, sender, IP, API key)
  • Prometheus metrics with persistence
  • Bounce handling
  • Graceful shutdown
  • Structured JSON logging

Requirements

  • Go 1.23+

Quick Start

For detailed quick start guide see docs/quickstart.md.

Build
go build -o sendry ./cmd/sendry
Configuration

Copy and edit the example configuration:

cp configs/sendry.example.yaml config.yaml

Minimal configuration:

server:
  hostname: "mail.example.com"

smtp:
  domain: "example.com"
  auth:
    required: true
    users:
      myuser: "mypassword"

api:
  api_key: "your-secret-api-key"

storage:
  path: "./data/queue.db"
Run
./sendry serve -c config.yaml
Validate Configuration
./sendry config validate -c config.yaml

API

Health Check
curl http://localhost:8080/health

Response:

{
  "status": "ok",
  "version": "0.2.0",
  "uptime": "1h30m",
  "queue": {
    "pending": 5,
    "sending": 1,
    "delivered": 100,
    "failed": 2,
    "deferred": 3,
    "total": 111
  }
}
Send Email
curl -X POST http://localhost:8080/api/v1/send \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "from": "sender@example.com",
    "to": ["recipient@example.com"],
    "subject": "Test",
    "body": "Hello, World!",
    "html": "<p>Hello, <b>World</b>!</p>"
  }'

Response:

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "pending"
}
Check Status
curl http://localhost:8080/api/v1/status/{message_id} \
  -H "Authorization: Bearer YOUR_API_KEY"

Response:

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "delivered",
  "from": "sender@example.com",
  "to": ["recipient@example.com"],
  "created_at": "2024-01-15T10:30:00Z",
  "updated_at": "2024-01-15T10:30:05Z",
  "retry_count": 0
}
Queue Stats
curl http://localhost:8080/api/v1/queue \
  -H "Authorization: Bearer YOUR_API_KEY"
Delete Message
curl -X DELETE http://localhost:8080/api/v1/queue/{message_id} \
  -H "Authorization: Bearer YOUR_API_KEY"

Configuration Reference

Parameter Default Description
server.hostname OS hostname Server FQDN
smtp.listen_addr :25 SMTP relay port
smtp.submission_addr :587 SMTP submission port
smtp.smtps_addr :465 SMTPS port (implicit TLS)
smtp.domain required Mail domain
smtp.max_message_bytes 10485760 Max message size (10MB)
smtp.max_recipients 100 Max recipients per message
smtp.auth.required false Require authentication
smtp.auth.users {} Username -> password map
smtp.tls.cert_file "" TLS certificate file path
smtp.tls.key_file "" TLS private key file path
smtp.tls.acme.enabled false Enable Let's Encrypt
smtp.tls.acme.email "" ACME account email
smtp.tls.acme.domains [] Domains for certificate
smtp.tls.acme.cache_dir /var/lib/sendry/certs Certificate cache
dkim.enabled false Enable DKIM signing
dkim.selector "" DKIM selector
dkim.domain "" DKIM domain
dkim.key_file "" DKIM private key path
api.listen_addr :8080 HTTP API port
api.api_key "" API key (empty = no auth)
queue.workers 4 Number of delivery workers
queue.retry_interval 5m Base retry interval
queue.max_retries 5 Max delivery attempts
storage.path /var/lib/sendry/queue.db BoltDB file path
storage.retention.delivered_max_age 0 Delete delivered messages older than this
storage.retention.cleanup_interval 1h Cleanup interval
dlq.enabled true Enable dead letter queue
dlq.max_age 0 Delete DLQ messages older than this
dlq.max_count 0 Max DLQ messages (0 = unlimited)
dlq.cleanup_interval 1h DLQ cleanup interval
logging.level info Log level (debug/info/warn/error)
logging.format json Log format (json/text)
metrics.enabled false Enable Prometheus metrics
metrics.listen_addr :9090 Metrics server port
metrics.path /metrics Metrics endpoint path
metrics.flush_interval 10s Counter persistence interval
metrics.allowed_ips [] IPs/CIDRs allowed to access metrics

See HTTP API reference, TLS and DKIM documentation, Message retention and DLQ, Rate limiting, and Prometheus metrics for detailed instructions.

Project Structure

sendry/
├── cmd/sendry/          # CLI entry point
├── internal/
│   ├── api/             # HTTP API server
│   ├── app/             # Application orchestration
│   ├── config/          # Configuration
│   ├── dkim/            # DKIM signing
│   ├── dns/             # MX resolver
│   ├── metrics/         # Prometheus metrics
│   ├── queue/           # Message queue & storage
│   ├── smtp/            # SMTP server & client
│   └── tls/             # TLS/ACME support
├── configs/             # Example configurations
└── docs/                # Documentation

License

GPL-3.0

Directories

Path Synopsis
cmd
sendry command
internal
api
app
dns
tls

Jump to

Keyboard shortcuts

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