srmilter
A Rust library for building mail filter (milter) daemons that integrate with Postfix.
Overview
srmilter implements the milter protocol to receive emails from Postfix, parse them, and return classification decisions (accept, reject, or quarantine). It provides a simple API for writing custom email classifiers.
Features
- Milter protocol implementation for Postfix integration
- Email parsing via
mail-parsercrate - Multiple concurrency modes: single-threaded, forked processes, or threaded
- Spamhaus ZEN DNSBL lookup utilities
- systemd socket activation support (optional)
- Built-in CLI with test and dump commands
Usage
-
Create a new binary crate:
-
Add srmilter as a dependency:
-
Edit
src/main.rsto create your milter binary (see example below).
Example
use ;
CLI Commands
The built-in CLI provides three subcommands:
# Run the milter daemon (default: 0.0.0.0:7044)
# Test classifier against an .eml file
# Dump parsed email headers and body
Concurrency Options
- Default: Single-threaded, sequential processing
--fork N: Fork up to N child processes (requiresenable_fork_mode())--threads N: Use up to N threads
Postfix Configuration
Add to your Postfix main.cf:
smtpd_milters = inet:127.0.0.1:7044
License
Copyright © 2025 Donald Buczek buczek@molgen.mpg.de
Licensed under the European Union Public Licence (EUPL), Version 1.2. See the LICENSE file for details.