Trait mailin_embedded::Handler
source · 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§
sourcefn helo(&mut self, _ip: IpAddr, _domain: &str) -> Response
fn helo(&mut self, _ip: IpAddr, _domain: &str) -> Response
Called when a client sends a ehlo or helo message
sourcefn mail(&mut self, _ip: IpAddr, _domain: &str, _from: &str) -> Response
fn mail(&mut self, _ip: IpAddr, _domain: &str, _from: &str) -> Response
Called when a mail message is started
sourcefn data_start(
&mut self,
_domain: &str,
_from: &str,
_is8bit: bool,
_to: &[String]
) -> Response
fn data_start( &mut self, _domain: &str, _from: &str, _is8bit: bool, _to: &[String] ) -> Response
Called when a data command is received
sourcefn auth_plain(
&mut self,
_authorization_id: &str,
_authentication_id: &str,
_password: &str
) -> Response
fn auth_plain( &mut self, _authorization_id: &str, _authentication_id: &str, _password: &str ) -> Response
Called when a plain authentication request is received
sourcefn auth_login(&mut self, _username: &str, _password: &str) -> Response
fn auth_login(&mut self, _username: &str, _password: &str) -> Response
Called when a login authentication request is received