AnyEvent-Postfix-Logs

 view release on metacpan or  search on metacpan

lib/AnyEvent/Postfix/Logs.pm  view on Meta::CPAN


=item on_mail (callback)

Reference to a handler to called for each mail fully completed by postfix.  It
vill be invoked as

    $on_mail->($mail)

where C<$mail> is a hashref with keys like C<from> (string), C<to> (array of
strings), C<time> (string), C<size> (integer), C<delay> (decimal point), and
C<msgid> (string).

=item on_finish (callback)

Reference to a handler called when all sources are depleted. It will be
invoked as

    $on_finish->()

=item on_error (callback)

lib/AnyEvent/Postfix/Logs.pm  view on Meta::CPAN


                $self->{on_mail}->($mail);
                delete $self->{messages}->{$server, $id};

            } else {
                $mail->{from} = $1 if $line =~ /^from=<([^>]+)>/;
                $mail->{size} = $1 if $line =~ /size=(\d+)/;
            }

        } elsif ( $cmd eq 'cleanup' ) {
            $mail->{msgid} = $1 if $line =~ /^message-id=(<[^>]+>)/;
        } elsif ( $cmd eq 'virtual' ) {
            push @{ $mail->{to} }, $1 if $line =~/^to=<([^>]+)>/;
            $mail->{delay} = $1 if $line =~ /delay=(\d+\.\d+)/;
        }

    }

    $handle->push_read( line => sub { $self->parseline( @_ ) } );
}



( run in 1.927 second using v1.01-cache-2.11-cpan-ceb78f64989 )