MCPSERV.CLUB
E-MailRelay

E-MailRelay

Self-Hosted

Lightweight SMTP store‑and‑forward server with POP access and spam filtering

Stale(40)
0stars
0views

Overview

Discover what makes E-MailRelay powerful

E‑MailRelay is a **lightweight, store‑and‑forward SMTP server** designed for self‑hosted environments. It accepts inbound mail via the standard **SMTP port 25** (with optional TLS) and stores messages in a local `maildir` format. The daemon can then forward the queued mail to a configured **smarthost** or perform DNS‑MX routing on a per‑recipient basis. The same binary also exposes a **POP3 interface** for clients to retrieve the stored mail, making it suitable both as an outbound relay and a minimal personal mailbox.

Language

Core libraries

Data storage

Extensibility

Overview

E‑MailRelay is a lightweight, store‑and‑forward SMTP server designed for self‑hosted environments. It accepts inbound mail via the standard SMTP port 25 (with optional TLS) and stores messages in a local maildir format. The daemon can then forward the queued mail to a configured smarthost or perform DNS‑MX routing on a per‑recipient basis. The same binary also exposes a POP3 interface for clients to retrieve the stored mail, making it suitable both as an outbound relay and a minimal personal mailbox.

Technical Stack & Architecture

  • Language: C, yielding high performance and low memory footprint.
  • Core libraries: OpenSSL for TLS support, libpam for authentication, and POSIX sockets for network I/O.
  • Data storage: maildir directories on the local filesystem; no external database is required.
  • Extensibility: A plug‑in‑style filter system where each mail message passes through a configurable chain of filters (e.g., spam, copy, deliver). Filters are invoked via simple command scripts or compiled shared objects, allowing developers to insert custom logic without modifying the core.
  • Process model: Single‑process with optional child workers for handling concurrent SMTP/POP connections. The daemon can be launched via systemd socket activation or as a standalone service, supporting Unix domain sockets and SOCKS proxies for flexible deployment.

Core Capabilities & APIs

  • SMTP/POP3 servers with full RFC‑5321 and RFC‑1939 compliance, including STARTTLS, authentication (PAM or custom), and submission extensions.
  • Filtering pipeline: Built‑in filters (spam, copy, deliver, split) and the ability to add custom ones. Filters receive environment variables describing the message (e.g., RCPT_TO, MAIL_FROM) and can modify headers or content before forwarding.
  • Address verification: Optional external address verifier servers (e.g., SMTP RCPT‑TO checks) and built‑in DNSBL lookups for blocking unwanted senders.
  • Rate limiting & retry logic: Configurable per‑recipient or global limits, with exponential back‑off for failed deliveries.
  • Delivery status notifications (DSN): Generates bounce messages on failure, integrating with the maildir store.
  • Web‑based administration interface: Exposes real‑time statistics, queue inspection, and configuration editing over HTTPS, protected by the same authentication mechanisms as SMTP/POP.

Deployment & Infrastructure

E‑MailRelay is container‑ready; a minimal Docker image can expose ports 25, 110, and the admin interface. It requires only a writable directory for maildir storage and an outbound network connection to the smarthost. Because it runs in a single process, horizontal scaling is achieved by deploying multiple instances behind an external load balancer or using a reverse‑proxy that supports SMTP connection pooling. The daemon’s small footprint (≈ 10 MB binary) and reliance on standard libraries make it ideal for edge devices, VPS hosts, or Kubernetes pods.

Integration & Extensibility

  • Plugin system: Developers can write custom filters in any language that reads from stdin and writes to stdout, or compile them as shared objects loaded at runtime.
  • Webhooks: The admin interface can trigger external HTTP callbacks on queue events (e.g., delivery success/failure).
  • API: A REST‑like JSON API is available for programmatic queue inspection and mail injection, useful for integrating with CI/CD pipelines or microservices that need to send transactional emails.
  • Configuration DSL: A declarative configuration file (relay.conf) supports nested sections, variable interpolation, and includes, allowing complex routing rules without code changes.

Developer Experience

The documentation is concise yet thorough, covering command‑line options, configuration syntax, and filter development. Inline comments in the config file serve as a living reference. The project’s community is active on GitHub, with issue trackers for bug reports and pull requests for new filters. Licensing under the GPLv3 ensures that any derivative work remains open source, encouraging contributions and fostering a shared ecosystem of plugins.

Use Cases

  1. Personal mail server: A developer can run E‑MailRelay on a home router or NAS to receive and forward mail with SpamAssassin filtering.
  2. Transactional email gateway: Applications that generate emails (e.g., account verification) can inject messages into the maildir, letting E‑MailRelay handle queuing, retries, and delivery to an SMTP provider.
  3. Email archiving: By configuring the copy filter to duplicate messages into a separate directory, developers can create an immutable audit trail for compliance.
  4. SMTP relay in CI pipelines: Continuous‑integration services can use E‑MailRelay as a lightweight SMTP server to test email delivery without exposing the actual provider.

Advantages Over Alternatives

  • Performance: The C implementation processes thousands of messages per second with minimal CPU usage, outperforming many interpreted MTAs.
  • Simplicity: No database or complex service mesh is required; a single binary plus a maildir directory suffices.
  • Extensibility: The filter chain lets developers inject custom logic without patching the core, unlike monolithic MTAs.
  • Security: Built‑in DNSBL blocking and optional PAM authentication reduce exposure to spam and unauthorized

Open SourceReady to get started?

Join the community and start self-hosting E-MailRelay today