qpsmtpd/plugins/content_log
Robert Spier 90daeb3786 r483@dog: rspier | 2005-07-06 21:17:00 -0700
The great plugin renaming in the name of inheritance and standardization commit.
 
 1. new concept of standard hook_ names.
 2. Plugin::init
 3. renamed many subroutines in plugins (and cleaned up register subs)
 4. updated README.plugins
 


git-svn-id: https://svn.perl.org/qpsmtpd/trunk@479 958fd67b-6ff1-0310-b445-bb7760255be9
2005-07-07 04:17:39 +00:00

27 lines
671 B
Perl

# -*- perl -*-
# $Id$
#
# A simple example of a plugin that logs all incoming mail to a file.
# Useful for debugging other plugins or keeping an archive of things.
use POSIX qw:strftime:;
sub hook_data_post {
my ($self, $transaction) = @_;
# as a decent default, log on a per-day-basis
my $date = strftime("%Y%m%d",localtime(time));
open(my $out,">>mail/$date")
or return(DECLINED,"Could not open log file.. continuing anyway");
$transaction->header->print($out);
$transaction->body_resetpos;
while (my $line = $transaction->body_getline) {
print $out $line;
}
close $out;
return (DECLINED, "successfully saved message.. continuing");
}