Open Source · MIT License · Self-Hosted

Your Mail Server's AI-Powered Shield

Drop-in SMTP gateway that intercepts spam, viruses, and phishing before they reach your inbox. Cascaded ML classifiers, local LLM analysis, ClamAV scanning, and operator feedback loops — fully self-hosted.

9
Processing stages
100+
Configurable features
<5ms
FastText classify
~5MB
SMTP RSS idle
Nine Layers of Defense
Every inbound email passes through a multi-stage pipeline before it reaches your mail server. Most threats are stopped at the SMTP layer before the message body is ever analyzed.
1
🔒

Connection Checks

RBL/DNSBL, reverse DNS, FCrDNS, HELO validation, SPF, sender reputation, pre-banner detection, greet delay, and rate limiting — all before accepting DATA.

2
📄

Header Analysis

Injection detection, routing-loop detection, RFC 5322 compliance, subject anomaly scoring, and homoglyph/IDN punycode detection on From addresses.

3

Inline DATA Rejection

Content-hash blocklist, fuzzy SimHash matching, inline FastText classifier, SURBL/URIBL URL reputation, threat-intel feed lookup, and file-type magic-byte verification — all sub-millisecond.

4

DKIM / DMARC / ARC

Cryptographic verification of DKIM signatures, DMARC alignment evaluation, and optional ARC sealing for downstream trust. Runs only after cheap gates pass.

5
🛡

Antivirus Scan

ClamAV scans HTML bodies and attachments via INSTREAM TCP. Infected emails are quarantined immediately with the virus name recorded.

6
👁

OCR Extraction

Image attachments are sent to a Tesseract sidecar. Extracted text is fed into classification, catching image-based spam that evades text classifiers.

7
🤖

Cascade Classification

FastText (<5ms) → Bayesian → transformer. Confident verdicts skip the LLM entirely. Only borderline cases escalate to full AI analysis.

8
🧠

LLM Analysis

Ollama (local) or Claude (Anthropic API). Produces a spam score, category, confidence, reasoning, and URL risk analysis with full authentication context.

9
📚

Learn & Deliver

Quarantine releases and spam marks train the classifier. LLM auto-labels bridge knowledge to the fast stages. Clean mail is relayed with RFC 5321 retry.

Enterprise-Grade Protection, Fully Self-Hosted
Over 100 configurable features across 16 categories — all manageable from a real-time React dashboard without restarting any service.

Rust SMTP Server

Built on tokio for async I/O. Idles at ~5 MB RSS, handles thousands of concurrent connections. Full ESMTP-aware sender parsing with per-command timeouts.

Rust + Tokio
🤖

Multi-Provider AI

Switch between Ollama (local, free) and Claude (Anthropic API) from the dashboard — no restart. Supports llama3, qwen2.5, phi4, mistral, and all Claude models.

AI-Powered

Cascade Classifier

FastText (<5ms) → Bayesian (sub-ms) → transformer → LLM. Most emails are decided by fast stages, saving LLM costs and latency. Learns from operator feedback.

Self-Learning
🛡

ClamAV Antivirus

HTML bodies and attachments scanned via INSTREAM TCP protocol. Virus name recorded, infected emails quarantined. Signature version shown in the dashboard health panel.

Security
👁

OCR Image Scanning

Tesseract sidecar extracts text from image attachments (PNG, JPEG, GIF, TIFF, BMP, WEBP) — including images inside ZIP archives — before classification.

🔐

Email Authentication

Full SPF, DKIM verification, DMARC alignment evaluation, and optional ARC sealing (RFC 8617). Three-mode enforcement (off/tag/reject) for safe rollout.

RFC Compliant
🎯

Impersonation Detection

Three automatic detectors: same-domain spoofing, display-name-as-email attacks, and internal-sender collision with Cyrillic homoglyph folding. No manual VIP lists needed.

Zero-Config
📈

Sender Reputation

Per-IP and per-domain scores (0.0–1.0) computed hourly from spam/ham/reject/virus ratios. Five tiers drive configurable penalties and bonuses. Phishing guard suppresses bad bonuses.

📦

Content Disarm (CDR)

Strips active content from PDF, OOXML, and legacy OLE attachments — macros, JavaScript, launch actions, embedded files. Fail-open on parse errors. DKIM structure preserved.

New
🔎

Threat Intelligence

Periodic ingestion of URLhaus, Feodo Tracker, and ThreatFox feeds. Sender IPs, URL domains, and attachment hashes checked in-line during both SMTP and analysis phases.

👥

Multi-Tenant RBAC

General and domain admin roles, per-tenant policy overlays, three-tier allow/block lists (global/domain/mailbox), mailbox user self-service, and scoped audit logs.

📨

Quarantine & Digests

Self-service portal with HMAC-signed links. Periodic digest emails with one-click release. Virus block, high-score confirmation, and per-recipient preferences.

Full Visibility, Real-Time Control
React 18 admin dashboard with live WebSocket feed, detailed email analysis views, SMTP debug traces, and every setting adjustable without restarts.
Dashboard
Email Log
Quarantine
Reputation
Feedback
Blocked
SMTP Debug
Settings
Emails (24h)
2,847
+12% vs yesterday
Spam Rate
18.3%
-2.1% vs yesterday
Avg. Latency
42ms
cascade decisive
Viruses Blocked
7
ClamAV v0.104
Sender Subject Score Source Status
[email protected] Q4 Revenue Report 8 fasttext Delivered
[email protected] Verify your account immediately! 94 claude Quarantined
[email protected] Updated benefits enrollment 12 transformer Delivered
[email protected] YOU WON $5,000,000!!! 98 fasttext Quarantined
[email protected] Invoice #38291 attached 62 ollama Quarantined
Built for Performance and Reliability
Every component is containerized, fail-open by design, and tunable without restarts. Settings propagate within 60 seconds.

Rust SMTP

tokio async runtime, ~5 MB idle

Rust Worker

Analysis, relay, scheduler

🐍

Python API

FastAPI + uvicorn, 2 workers

React Dashboard

React 18 + TypeScript + Vite

🐘

PostgreSQL 16

Emails, settings, audit

Valkey 8

Task queue, cache, rate limits

🤖

Ollama / Claude

Local or cloud LLM inference

🛡

ClamAV

Antivirus daemon

👁

Tesseract OCR

Image text extraction sidecar

📊

ML Classifier

FastText + Bayesian + transformer

Fail-Open by Design

If any component is unavailable — Ollama, ClamAV, classifier, OCR — email is delivered rather than dropped. Availability is never sacrificed for filtering.

Zero-Restart Configuration

All runtime settings live in the database. Change the spam threshold, switch LLM models, toggle SMTP checks, or update rate limits from the dashboard. Changes propagate in 60 seconds.

Fully Self-Hosted

Your emails never leave your infrastructure. Local LLM via Ollama, local antivirus, local ML classifiers. Cloud API is optional — not required.

Up and Running in Five Minutes
Docker Compose handles everything. One clone, one configuration file, one command.
# 1. Clone the repository
git clone https://github.com/ahmetbuba/postarmor.git
cd postarmor

# 2. Configure your environment
make setup          # copies .env.example to .env
$EDITOR .env        # set DB_PASSWORD, BACKEND_SMTP_HOST, admin credentials

# 3. Start all services
make up             # build + start (~5 min first run, migrations auto-run)
make pull-model     # downloads llama3.2:3b (~2 GB, one-time)

# 4. Open the dashboard
open http://localhost
# Login with ADMIN_USERNAME / ADMIN_INITIAL_PASSWORD from .env

Point your MX records at port 25. Set BACKEND_SMTP_HOST to your real mail server, or configure per-domain routing from the dashboard.

Prerequisites

Docker Desktop 4.x+
Docker Compose v2+
make GNU 3.x+

Hardware (Minimum)

RAM 6 GB
Disk 10 GB free
CPU 4 cores

Hardware (Recommended)

RAM 16 GB
Disk 20 GB free
GPU NVIDIA 4+ GB VRAM

LLM Providers

Ollama (local) Free
Claude Haiku ~$40/day @ 25k
Claude Sonnet ~$152/day @ 25k

Take Back Control of
Your Email Security

No SaaS subscriptions. No data leaving your server. Open source, MIT licensed, and ready to deploy.