$ show gleez/smtpd
This is a lightweight SMTP server written in Go, designed to receive large volumes of email, parse MIME content, and store messages in MongoDB. It includes a web interface for viewing messages, managing greylisting, and real-time notifications via WebSockets (using the embedded Incus library). The server implements core SMTP commands (HELO/EHLO, MAIL, RCPT, DATA, AUTH, STARTTLS, XCLIENT) and supports TLS, greylisting, and spam filtering via regex. The architecture is monolithic: a single binary runs both the SMTP listener and an HTTP server for the web UI. The codebase is functional but shows signs of age: it uses deprecated dependencies (gopkg.in/mgo.v2, github.com/robfig/config, github.com/gosexy/redis), lacks a go.mod file, and has no automated tests. The SMTP protocol handling is reasonably robust, and the MIME parsing is non-trivial, but the overall project would benefit from modernization and testing.
The LLM identified 2 files worth highlighting for reuse:
Provides RFC3696-compliant email address parsing (ParseEmailAddress), domain validation (ValidateDomainPart), and mailbox name hashing. These functions are self-contained, have no internal dependencies, and can be extracted into any Go project needing robust email address handling. The implementation correctly handles quoted strings, escape characters, and domain label validation.
Implements secure XSRF token generation and validation using HMAC-SHA1 with a time-based expiry. The package is fully self-contained (only uses standard library crypto and encoding packages). It provides a clean API for generating tokens tied to a user ID and action, with constant-time comparison to prevent timing attacks. This can be reused in any web application requiring CSRF protection.