NAME
Mail::Colander::Server - SMTP server leveraging Mail::Colander
VERSION
This document describes Mail::Colander::Server version {{[ version ]}}.
SYNOPSIS
use Mail::Colander::Server qw< mojo_ioloop_server_callback_factory >;
my $mss = mojo_ioloop_server_callback_factory(
sieve => $mail_sieve_definition,
esmtp_extensions => [qw< PIPELINING >],
esmtp_args => { idle_timeout => 1 },
callback_for => {
HELO => sub ($session) { warn "accept HELO" },
EHLO => sub ($session) { warn "accept EHLO" },
DATA => sub ($session) { warn "accept DATA" },
reject => sub ($phase, $session) { warn "reject $phase" },
},
);
Mojo::IOLoop->server(port => $port, $mss);
Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
DESCRIPTION
ESMTP server that allows analyzing incoming messages via Mail::Colander/Data::Annotation and then act based on callbacks.
INTERFACE
mojo_ioloop_server_callback_factory
my $mss = mojo_ioloop_server_callback_factory(%args);
Do-it-all function that is a factory for a sub reference suitable to be passed to Mojo::IOLoop->server.
The input %args
support the following keys:
callback_for
: a hash reference of key/value pairs, where keys represent either a phase supported by Net::Server::Mail::ESMTP (likeEHLO
,DATA
, etc.) or keyreject
, and values are callback functions.The callback for
reject
takes two parameters, namely the phase where the rejection happened, and the Mail::Colander::Session object tracking the ESMTP session:sub reject_cb ($phase, $session) { ... }
All other callbacks take one single parameter, i.e. the Mail::Colander::Session:
sub phase_success_cb ($session) { ... }
esmtp_args
: list of arguments for creating an instance of class Net::Server::Mail::ESMTP.esmtp_extensions
: a list of extensions for Net::Server::Mail::ESMTP.sieve
: a Mail::Colander instance, or a hash reference with the data to create one.timeout
: the timeout set on each client connection stream in seconds, defaulting to 3.
ANYTHING ELSE (INCLUDING AUTHOR, COPYRIGHT AND LICENSE)
See documentation for Mail::Colander.