pub trait Handler {
    // Provided methods
    fn helo(&mut self, _ip: IpAddr, _domain: &str) -> Response { ... }
    fn mail(&mut self, _ip: IpAddr, _domain: &str, _from: &str) -> Response { ... }
    fn rcpt(&mut self, _to: &str) -> Response { ... }
    fn data_start(
        &mut self,
        _domain: &str,
        _from: &str,
        _is8bit: bool,
        _to: &[String]
    ) -> Response { ... }
    fn data(&mut self, _buf: &[u8]) -> Result<(), Error> { ... }
    fn data_end(&mut self) -> Response { ... }
    fn auth_plain(
        &mut self,
        _authorization_id: &str,
        _authentication_id: &str,
        _password: &str
    ) -> Response { ... }
    fn auth_login(&mut self, _username: &str, _password: &str) -> Response { ... }
}
Expand description

A Handler makes decisions about incoming mail commands.

A Handler implementation must be provided by code using the mailin library.

All methods have a default implementation that does nothing. A separate handler instance should be created for each connection.

§Examples


impl Handler for MyHandler {
    fn helo(&mut self, ip: IpAddr, domain: &str) -> Response {
       if domain == "this.is.spam.com" {
           OK
       } else {
           BAD_HELLO
       }
    }

    fn rcpt(&mut self, to: &str) -> Response {
       if to == "alienscience" {
           OK
       } else {
           NO_MAILBOX
       }
    }
}

Provided Methods§

source

fn helo(&mut self, _ip: IpAddr, _domain: &str) -> Response

Called when a client sends a ehlo or helo message

source

fn mail(&mut self, _ip: IpAddr, _domain: &str, _from: &str) -> Response

Called when a mail message is started

source

fn rcpt(&mut self, _to: &str) -> Response

Called when a mail recipient is set

source

fn data_start( &mut self, _domain: &str, _from: &str, _is8bit: bool, _to: &[String] ) -> Response

Called when a data command is received

source

fn data(&mut self, _buf: &[u8]) -> Result<(), Error>

Called when a data buffer is received

source

fn data_end(&mut self) -> Response

Called at the end of receiving data

source

fn auth_plain( &mut self, _authorization_id: &str, _authentication_id: &str, _password: &str ) -> Response

Called when a plain authentication request is received

source

fn auth_login(&mut self, _username: &str, _password: &str) -> Response

Called when a login authentication request is received

Implementors§