milter 0.1.6

Bindings to the sendmail milter library
docs.rs failed to build milter-0.1.6
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: milter-0.2.4

milter

The milter library provides Rust bindings to libmilter, the sendmail mail filter API.

This library serves the creation of milters: mail filtering applications that can be integrated with mail servers such as Postfix.

WORK IN PROGRESS – not yet released, feedback on API welcome

Requirements

This crate requires the milter C library (libmilter) to be available.

On Debian and Ubuntu, install the package libmilter-dev.

The integration tests of this crate use the third-party miltertest program to exercise the test milters. This program can be found among the OpenDKIM command-line tools.

On Debian and Ubuntu, install the package opendkim-tools (only required when working on the milter crate itself).

Usage

Include libc in addition to milter in Cargo.toml:

[dependencies]
milter = "0.1"
libc = "0.2"

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

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

#[on_connect(connect_callback)]
fn handle_connect(
    _: Context<()>,
    _: &str,
    socket_addr: Option<SocketAddr>,
) -> Status {
    if let Some(socket_addr) = socket_addr {
        println!("Connect from {}", socket_addr.ip());
    }

    Status::Continue
}

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

Refer to the API documentation for complete usage instructions.

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.