File: content_log

package info (click to toggle)
qpsmtpd 0.94-8
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,340 kB
  • sloc: perl: 17,176; sh: 543; makefile: 186; sql: 100
file content (25 lines) | stat: -rw-r--r-- 688 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!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 {
    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");
}