[][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.


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

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

Provided Methods

Called when a client sends a ehlo or helo message

Called when a mail message is started

Called when a mail recipient is set

Called when a data command is received

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

Called when a plain authentication request is received