[][src]Trait mailin_embedded::Handler

pub trait Handler {
    fn helo(&mut self, _ip: IpAddr, _domain: &str) -> HeloResult { ... }
fn mail(&mut self, _ip: IpAddr, _domain: &str, _from: &str) -> MailResult { ... }
fn rcpt(&mut self, _to: &str) -> RcptResult { ... }
fn data(
        &mut self,
        _domain: &str,
        _from: &str,
        _is8bit: bool,
        _to: &[String]
    ) -> DataResult { ... }
fn auth_plain(
        &mut self,
        _authorization_id: &str,
        _authentication_id: &str,
        _password: &str
    ) -> AuthResult { ... } }

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) -> HeloResult {
       if domain == "this.is.spam.com" {
           HeloResult::BadHelo
       } else {
           HeloResult::Ok
       }
    }

    fn rcpt(&mut self, to: &str) -> RcptResult {
       if to == "alienscience" {
           RcptResult::Ok
       } else {
           RcptResult::NoMailbox
       }
    }
}

Provided methods

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

Called when a client sends a ehlo or helo message

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

Called when a mail message is started

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

Called when a mail recipient is set

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

Called when a data command is received

This function must return a writer and the email body will be written to this writer.

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

Called when a plain authentication request is received

Loading content...

Implementors

Loading content...