$ show hmailserver/hmailserver
hMailServer is a production-grade, open-source email server for Microsoft Windows, implementing SMTP, POP3, and IMAP protocols with comprehensive anti-spam (SPF, DKIM, DMARC, DNSBL, SURBL, greylisting, SpamAssassin) and anti-virus (ClamAV, ClamWin, custom) capabilities. The server core is written in C++ using Boost.Asio for asynchronous I/O and exposes a COM automation API for administration. It is complemented by a .NET WinForms Administrator GUI, a PHP-based web admin, and a suite of database upgrade scripts supporting MySQL, MSSQL, PostgreSQL, and SQL Server Compact Edition. The architecture follows a layered pattern: business objects (e.g., Account, Domain, Rule) with a generic Collection/Persistence layer, a caching subsystem with TTL-based eviction, and a plugin-style spam test runner. Key data flows include message reception via SMTP, anti-spam scanning, local or external delivery, and optional virus scanning. External dependencies include OpenSSL, Boost, and database client libraries. The codebase is well-structured with reusable patterns but shows signs of age (manual memory management, COM, .NET Framework 4.5, PHP without modern framework).
The LLM identified 5 files worth highlighting for reuse:
Orchestrates a sequence of spam tests (Helo, PTR, MX, SPF, SURBL, DKIM, DMARC, DNSBL, SpamAssassin) with configurable thresholds and early exit on high spam score. Demonstrates a clean plugin architecture where each test inherits from SpamTest base class and is run in order. Reusable as a template for any multi-stage scoring pipeline.
Generic thread-safe cache template with configurable maximum size, TTL, and automatic eviction of oldest 10% when full. Used for accounts, domains, aliases, and distribution lists. Demonstrates a reusable caching pattern that can be extracted for any project needing bounded, time-based caching with minimal dependencies.
Implements modern password hashing using Argon2id and PBKDF2-SHA256 with PHC string format, configurable cost parameters, and automatic rehash detection. Includes legacy MD5/SHA256 migration support. Demonstrates a well-encapsulated, testable hashing utility that can be reused in any authentication system.
Parses SQL scripts containing dialect-specific macros (e.g., %HM_DROP_TABLE_COLUMN%) and expands them for MySQL, MSSQL, PostgreSQL, or SQLCE. Used for database upgrade scripts. Demonstrates a clean macro expansion pattern that can be adapted for any multi-database migration tool.
Manages a queue of I/O operations (connect, read, write, disconnect) with ordering constraints (e.g., write after read). Used in TCPConnection for asynchronous SSL/TLS connections. Demonstrates a reusable pattern for sequencing async operations with dependency tracking, applicable to any event-driven network library.