2012-04-29 01:35:59 -07:00
|
|
|
#!perl -w
|
2012-04-07 20:11:16 -04:00
|
|
|
|
2002-11-01 02:08:38 +00:00
|
|
|
# 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:;
|
|
|
|
|
2005-07-07 04:17:39 +00:00
|
|
|
sub hook_data_post {
|
2013-04-21 00:50:39 -04:00
|
|
|
my ($self, $transaction) = @_;
|
2002-11-01 02:08:38 +00:00
|
|
|
|
2013-04-21 00:50:39 -04:00
|
|
|
# as a decent default, log on a per-day-basis
|
|
|
|
my $date = strftime("%Y%m%d", localtime(time));
|
|
|
|
open(my $out, ">>mail/$date")
|
2014-09-17 20:28:51 -05:00
|
|
|
or return DECLINED, "Could not open log file.. continuing anyway";
|
2002-11-01 02:08:38 +00:00
|
|
|
|
2013-04-21 00:50:39 -04:00
|
|
|
$transaction->header->print($out);
|
|
|
|
$transaction->body_resetpos;
|
|
|
|
while (my $line = $transaction->body_getline) {
|
|
|
|
print $out $line;
|
|
|
|
}
|
2002-11-01 02:08:38 +00:00
|
|
|
|
2013-04-21 00:50:39 -04:00
|
|
|
close $out;
|
2002-11-01 02:08:38 +00:00
|
|
|
|
2014-09-17 20:28:51 -05:00
|
|
|
return DECLINED, "successfully saved message.. continuing";
|
2002-11-01 02:08:38 +00:00
|
|
|
}
|