milter

The milter crate provides Rust bindings for libmilter, the sendmail mail filter API.

This library can be used to create milters: mail filtering applications that can be integrated with mail servers such as [Postfix].

WORK IN PROGRESS – NOT YET RELEASED

Requirements

This crate expects the libmilter C library to be available. On Debian and Ubuntu, install the libmilter-dev package.

The integration tests of this crate require the miltertest program. On Debian and Ubuntu, this is provided by the opendkim-tools package.

Usage

Include libc in addition to milter in the dependencies:

toml [dependencies] milter = "0.1.3" libc = "0.2"

Here’s a simple milter application that logs client IP addresses:

```rust use milter::{on_connect, Context, Milter, Status}; use std::net::SocketAddr;

[onconnect(connectcallback)]

fn handleconnect( _: Context<()>, _: &str, socketaddr: Option ) -> Status { if let Some(socketaddr) = socketaddr { println!("Connect from {}", socket_addr.ip()); }

Status::Continue

}

fn main() { Milter::new("unix:/run/ipmilter.sock") .name("IPMilter") .onconnect(connectcallback) .run() .expect("milter execution failed"); } ```

See the documentation for more, https://docs.rs/milter.

Licence

Copyright © 2019 David Bürgin

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.