#email #milter #postfix #sendmail #smtp

indymilter

Asynchronous milter library

2 releases

Uses new Rust 2021

0.0.2 Nov 15, 2021
0.0.1 Oct 17, 2021

#3 in #postfix

Download history 16/week @ 2021-10-12 17/week @ 2021-10-19 3/week @ 2021-10-26 2/week @ 2021-11-02 22/week @ 2021-11-09 15/week @ 2021-11-16 13/week @ 2021-11-23

52 downloads per month

GPL-3.0-or-later

105KB
2.5K SLoC

indymilter

(in development)

Stand-alone asynchronous milter library.

  • pure safe Rust, no dependency on C library
  • asynchronous paradigm, implementation based on Tokio
  • free software

Example

Here is a simple but complete milter program that logs client IP addresses:

use indymilter::{Callbacks, Context, SocketInfo, Status};
use tokio::{net::UnixListener, signal};

#[tokio::main]
async fn main() {
    let config = Default::default();

    let callbacks = Callbacks::new()
        .on_connect(|context, _, socket_info| {
            Box::pin(handle_connect(context, socket_info))
        });

    let listener = UnixListener::bind("/run/ipmilter.sock")
        .expect("cannot open milter socket");

    indymilter::run(listener, callbacks, config, signal::ctrl_c())
        .await
        .expect("milter execution failed");
}

async fn handle_connect(
    _: &mut Context<()>,
    socket_info: Option<SocketInfo>,
) -> Status {
    if let Some(SocketInfo::Inet(addr)) = socket_info {
        println!("connect from {}", addr.ip());
    }

    Status::Continue
}

Licence

Copyright © 2021 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.

Dependencies

~4MB
~72K SLoC

Wqa