MCPSERV.CLUB
Sendmail

Sendmail

Self-Hosted

Enterprise‑grade open source email server for complex environments

Stale(40)
0stars
0views
Sendmail screenshot 1
1 / 2

Overview

Discover what makes Sendmail powerful

Sendmail is a mature, open‑source Mail Transfer Agent (MTA) that has powered email delivery for decades. From a developer’s standpoint, it is a highly configurable daemon written primarily in C that implements the SMTP protocol and related mail handling standards (RFC 5321, RFC 5322, etc.). The core of Sendmail is the `sendmail` binary, which parses incoming and outgoing mail headers, applies routing rules, performs anti‑spam checks, and hands messages to local delivery agents or remote SMTP servers. The configuration is expressed through a domain‑specific language (the `sendmail.cf` file), which can be generated from human‑readable macros in `m4`. This approach gives developers granular control over every aspect of mail flow, from aliasing and virtual domains to sophisticated policy checks.

Language & Runtime

Configuration

Databases

Modules & Hooks

Overview

Sendmail is a mature, open‑source Mail Transfer Agent (MTA) that has powered email delivery for decades. From a developer’s standpoint, it is a highly configurable daemon written primarily in C that implements the SMTP protocol and related mail handling standards (RFC 5321, RFC 5322, etc.). The core of Sendmail is the sendmail binary, which parses incoming and outgoing mail headers, applies routing rules, performs anti‑spam checks, and hands messages to local delivery agents or remote SMTP servers. The configuration is expressed through a domain‑specific language (the sendmail.cf file), which can be generated from human‑readable macros in m4. This approach gives developers granular control over every aspect of mail flow, from aliasing and virtual domains to sophisticated policy checks.

Architecture

  • Language & Runtime: C (≈ 300 k lines), compiled with GCC or Clang, runs as a single long‑lived process.
  • Configuration: sendmail.cf (compiled from m4 macros). The macro system allows embedding logic, regular expressions, and conditional statements.
  • Databases: Supports multiple back‑ends for mail routing—hash, dbm, gdbm, and SQL via the smtpd_relay module. For large deployments, administrators often integrate PostgreSQL or MySQL for alias tables and policy checks.
  • Modules & Hooks: Loadable modules (sendmail.c, smtpd_relay, check_rcpt, etc.) enable extensibility. The sendmail binary can be extended with custom C modules compiled against the Sendmail API.
  • Logging & Monitoring: Syslog integration, maillog, and optional external log shippers (e.g., Fluentd) for observability.

Core Capabilities

  • SMTP & SMTP‑TLS: Full compliance with modern TLS extensions (STARTTLS, SNI) and support for modern cipher suites.
  • Policy Checks: check_policy_service allows external services (e.g., spam filters, DKIM validators) to influence routing decisions.
  • Virtual Domains & Mailboxes: Native support for virtual domains, per‑user maildir or mbox storage, and mailbox forwarding.
  • Transport Maps: Flexible transport maps (/etc/mail/sendmail.mcsendmail.cf) enable per‑recipient routing, load balancing, and failover.
  • Milter Interface: The Mail Filter (milter) API lets developers write C or higher‑level language extensions that inspect and modify mail in transit.
  • SMTP Authentication: Supports SASL mechanisms (PLAIN, LOGIN, CRAM‑MD5) via the smtpd daemon.

Deployment & Infrastructure

Sendmail can be deployed on any POSIX‑compatible host (Linux, BSD, macOS). For modern cloud environments, it is commonly containerized using Docker or Kubernetes:

  • Containerization: A minimal base image (Alpine, Debian Slim) with the Sendmail binary and a pre‑generated sendmail.cf. Configuration files can be mounted as ConfigMaps or Secrets.
  • Scalability: Horizontal scaling is achieved by running multiple instances behind a load balancer (e.g., HAProxy) with shared routing tables or by using sendmail’s built‑in relay mode for clustering.
  • High Availability: Replicated databases (PostgreSQL, MySQL) and shared mail storage (NFS, Ceph) ensure redundancy. The sendmail process itself is stateless after initialization, simplifying failover.

Integration & Extensibility

  • Milter Plugins: Developers can write milter plugins in C, Python (via pymilter), or Go (gomilter). These plug‑ins can perform spam scoring, DKIM signing, content filtering, or custom routing logic.
  • External Policy Services: check_policy_service can call any HTTP/SMTP service. This is commonly used to integrate with third‑party reputation services or internal corporate policies.
  • Webhooks & APIs: While Sendmail itself does not expose a REST API, many organizations wrap it with lightweight HTTP services that query the mail queue or trigger re‑routing. The sendmail command line (-q, -d) can be invoked from scripts.
  • Custom Modules: The Sendmail API allows linking custom C modules (.so files) that can hook into the message processing pipeline, providing deep integration points.

Developer Experience

  • Documentation: The official Sendmail documentation is extensive but dense. Key resources include the sendmail.mc macro manual, RFC references, and community‑maintained guides (e.g., on the Sendmail project wiki).
  • Community & Support: An active mailing list (sendmail-users@lists.sourceforge.net) and a dedicated CERT advisory channel provide timely security updates. Commercial support is available from vendors that maintain Sendmail distributions.
  • Configuration Complexity: The macro system can be daunting; however, once the sendmail.mc templates are mastered, generating a clean sendmail.cf is straightforward. Tools like m4 and make automate this process.
  • Testing: Unit testing of configuration changes is typically performed with sendmail -bt (testing the mailbox lookup) and custom test harnesses that send SMTP sessions to a

Open SourceReady to get started?

Join the community and start self-hosting Sendmail today