Peter Makholm


AnyEvent::Postfix::Logs - Event based parsin of Postfix log files


    use AnyEvent::Postfix::Logs;

    my $cv = AnyEvent->condvar;

        sources   => [ \*STDIN ],
        on_mail   => sub { say "Mail from $_[0]->{from} to ", join(", ", @{ $_[0]->{to} } ) },
        on_finish => sub { say "No more mail"; $cv->send() },
        on_error  => sub { croak $_[0] },

    # do some more stuff



This module implement parsing of postfix log files from multiple sources. Each time a mail is removed from postfix' queue a callback is invoked with collected information about the mail.

Warning: This module is developen on an need to do basis for ad hoc-problems. Do not expect it to be a complete implementation, but if you need adtional features pleaes submit a bug.



Creates a new instance of a AnyEvent::Postfix::Logs module


sources (array of sources)

Valid sources are perl file handles or names of log files

on_mail (callback)

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


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

on_finish (callback)

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

on_error (callback)

Reference to a handler called when an error occurs. It will be invoked as


Default is to croak


Add a list of additional sources


Peter Makholm, <peter at>


Please report any bugs or feature requests to bug-anyevent-postfix-logs at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

    perldoc AnyEvent::Postfix::Logs

You can also look for information at:



Copyright 2009 Peter Makholm.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See for more information.