2012-06-22 11:38:01 +02:00
|
|
|
#!perl -w
|
|
|
|
|
|
|
|
# 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 {
|
2013-04-21 06:50:39 +02:00
|
|
|
my ($self, $transaction) = @_;
|
2012-06-22 11:38:01 +02:00
|
|
|
|
2013-04-21 06:50:39 +02:00
|
|
|
# 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");
|
2012-06-22 11:38:01 +02:00
|
|
|
|
2013-04-21 06:50:39 +02:00
|
|
|
$transaction->header->print($out);
|
|
|
|
$transaction->body_resetpos;
|
|
|
|
while (my $line = $transaction->body_getline) {
|
|
|
|
print $out $line;
|
|
|
|
}
|
2012-06-22 11:38:01 +02:00
|
|
|
|
2013-04-21 06:50:39 +02:00
|
|
|
close $out;
|
2012-06-22 11:38:01 +02:00
|
|
|
|
2013-04-21 06:50:39 +02:00
|
|
|
return (DECLINED, "successfully saved message.. continuing");
|
2012-06-22 11:38:01 +02:00
|
|
|
}
|