This repository has been archived on 2023-09-20. You can view files and clone it, but cannot push or open issues or pull requests.
rust-opensmtpd/examples/dummy.rs

22 lines
564 B
Rust
Raw Normal View History

use log::debug;
2018-12-29 21:03:33 +01:00
use env_logger::{Builder, Env};
use opensmtpd::{handlers, Entry, EventHandler, MatchEvent, SmtpIn};
fn on_event(entry: &Entry) -> bool {
debug!("Event received: {:?}", entry);
true
}
2018-12-29 21:03:33 +01:00
// This function should be replaced by a procedural macro on
// the `on_event` function.
fn on_event_builder() -> EventHandler {
EventHandler::new(MatchEvent::All, on_event)
}
fn main() {
2018-12-29 21:03:33 +01:00
Builder::from_env(Env::default().default_filter_or("debug")).init();
SmtpIn::new()
.event_handlers(handlers!(on_event_builder))
.run();
}