NAME

Mail::Sieve::Server - SMTP server leveraging Mail::Sieve

VERSION

This document describes Mail::Sieve::Server version {{[ version ]}}.

Build Status Perl Version Current CPAN version Kwalitee CPAN Testers CPAN Testers Matrix

SYNOPSIS

use Mail::Sieve::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::Sieve/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 (like EHLO, DATA, etc.) or key reject, and values are callback functions.

    The callback for reject takes two parameters, namely the phase where the rejection happened, and the Mail::Sieve::Session object tracking the ESMTP session:

    sub reject_cb ($phase, $session) { ... }

    All other callbacks take one single parameter, i.e. the Mail::Sieve::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::Sieve 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::Sieve.