Mail::Log::Parse::Postfix - Parse and return info in Postfix maillogs


  use Mail::Log::Parse::Postfix;

(See Mail::Log::Parse for more info.)


This is a subclass of Mail::Log::Parse, which handles parsing for Postfix mail logs.



Sets the year, for the log timestamps. If not set, the log is assumed to be for the current year. (Can also be passed in new, with the key 'year'.)


Returns a hash of the next line of postfix log data.

Hash keys are:

        delay_before_queue, delay_connect_setup, delay_in_queue, 
        delay_message_transmission, from, host, id, msgid, pid, program, 
        relay, size, status, text, timestamp, to, delay, connect,
        disconnect, previous_host, previous_host_name, previous_host_ip

All keys are guaranteed to be present. 'program', 'pid', 'host', 'timestamp', 'id' and 'text' are guaranteed to have a value. 'connect' and 'disconnect' are boolean: true if the line is the relevant type of line, false otherwise.

The 'text' key will have all of the log text after the standard Postfix header. (All of which is in the other keys that are required to have a value.)


None known at the moment.


Scalar::Util, Time::Local, Mail::Log::Parse, Mail::Log::Exceptions, Memoize


Daniel T. Staal


Mail::Log::Parse, for the main documentation on this module set.


April 17, 2009 (1.5.1) - No longer uses _set_current_position_as_next_line, instead lets Mail::Log::Parse manage automatically. (Requires 1.4.0.)

April 9, 2009 (1.5.0) - Now reads the connecting host from the 'connect' and 'disconnect' lines in the log.

Feb 27, 2009 (1.4.12) - Quieted an occasional error, if the log line doesn't have the standard Postfix format.

Dec 23, 2008 (1.4.11) - Further speedups. Now requires Mail::Log::Parse of at least version 1.3.0.

Dec 09, 2008 (1.4.10) - Profiled code, did some speedups. Added dependency on Memoize: For large logs this is a massive speedup. For extremely sparse logs it may not be, but sparse logs are likely to be small.

Nov 28, 2008 - Switched 'total_delay' to slightly more universal 'delay'. Sped up some regexes.

Nov 11, 2008 - Switched to using the bufferable _parse_next_line instead of the unbuffered next.

Nov 6, 2008 - Added set_year and alternate year handling, in case we aren't dealing with this year's logs. (From the todo list.)

Oct 24, 2008 - Added 'connect' and 'disconnect' members to the return hash.

Oct 6, 2008 - Initial version.


Copyright (c) 2008 Daniel T. Staal. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

This copyright will expire in 30 years, or 5 years after the author's death, whichever is longer.