← Back to Projects

Exchange · AI Security

AI Mail Gateway

AiMailProxy for Microsoft Exchange

An inbound SMTP proxy that inspects mail before Exchange — layered auth, link and attachment scans, and LLM-based SCL 0–9 for transport rules.

  • Inbound SMTP proxy
  • Python · aiosmtpd
  • SCL 0–9 · Exchange rules
  • On-prem edge
AI Mail Gateway dashboard showing architecture, live filter results, and SCL details

Filter at the edge. Classify for Exchange.

Known-bad senders can be rejected at SMTP with 550. Everything else is analyzed, tagged with SCL and risk headers, then relayed so Exchange transport rules can junk or quarantine without rewriting the mailbox path.

Layered defense

Blacklist and whitelist, SPF/DKIM/DMARC, attachment and URL reputation, then AI SCL — no single signal decides alone.

Exchange-native SCL

AI assigns Microsoft-compatible SCL 0–9 plus optional Subject prefixes and custom headers for existing transport rules.

Cost-aware AI

A body classification cache confirms repeat campaigns after a few analyses, then skips further LLM calls for matching mail.

Inspection pipeline

Every message gets a full Check log.

After SMTP DATA, the proxy parses the message, runs auth and scans, classifies with AI or cache, applies SCL floors, then relays — with per-check outcomes visible in the console and daily logs.

  • Auth, blacklist, peer IP, attachments, URL targets
  • Cache hit/miss and AI SCL with latency
  • Header write and SMTP relay status (250 / 550)
AI Mail Gateway live filter results with blocked phishing and SCL scores

AI SCL

LLM classification aligned to Exchange SCL.

Cerebras or Groq classifies subject, senders, recipients, attachment names, and a body preview into SCL 0–9 via a hot-reloaded prompt. Auth failures, brand impersonation, and high-risk attachments raise floors so weak signals still raise the score before relay.

  • Providers: Cerebras / Groq (key-based selection)
  • Whitelist + auth policy can skip AI while links and attachments still run
  • Defer queue when AI is temporarily unavailable

Threat signals

Links, attachments, and peer reputation.

URLs are checked with APIVoid then VirusTotal. Attachments use banned extensions, zip recursion, magic-byte filetype detection, and oletools macro analysis. SMTP peer IPs can be scored on VirusTotal, including recovery of originating IP when mail arrives via a trusted TMES gateway.

  • X-AiMailProxy-LinkRisk / PeerRisk / Malicious headers
  • Optional composite 550 when auth fail + threat + high body SCL align
  • Hot-reload blacklist, whitelist, prompt, and spam_level files

How it works

  1. 1

    Receive at the edge

    Inbound MX or connector delivers SMTP to AiMailProxy before Exchange. Exact recipient blacklist can reject at RCPT.

  2. 2

    Inspect and classify

    Whitelist/blacklist, auth, attachments, links, cache or AI SCL, then floors and optional composite reject.

  3. 3

    Relay with policy hooks

    Add X-AiMailProxy-* headers and Subject prefixes, then SMTP-relay to Exchange for Junk, phishing, or quarantine rules.

Built for on-prem Exchange

Python SMTP edge service with monitor mode for safe rollout, daily stats and optional report mail, spammer accumulation, and Windows-friendly operation.

Development / My Role

I design and build AiMailProxy end to end — the SMTP receive/relay path, multi-layer inspection pipeline, AI SCL protocol and caching, Exchange header integration, and operational tooling for logs, stats, and hot-reloaded policy files.

Built with Python, aiosmtpd, aiohttp, pyspf, dkimpy, VirusTotal / APIVoid integrations, and LLM APIs (Cerebras / Groq).