1 ## $Id: sendme.pl 4932 2001-07-19 00:32:56Z rra $
3 ## sendme control message handler.
5 ## Copyright 2001 by Marco d'Itri <md@linux.it>
7 ## Redistribution and use in source and binary forms, with or without
8 ## modification, are permitted provided that the following conditions
11 ## 1. Redistributions of source code must retain the above copyright
12 ## notice, this list of conditions and the following disclaimer.
14 ## 2. Redistributions in binary form must reproduce the above copyright
15 ## notice, this list of conditions and the following disclaimer in the
16 ## documentation and/or other materials provided with the distribution.
21 my ($par, $sender, $replyto, $site, $action, $log, $approved,
22 $headers, $body) = @_;
24 if ($action eq 'mail') {
25 my $mail = sendmail("sendme by $sender");
26 print $mail map { s/^~/~~/; "$_\n" } @$body;
27 close $mail or logdie('Cannot send mail: ' . $!);
28 } elsif ($action eq 'log') {
30 logger($log, "sendme $sender", $headers, $body);
32 logmsg("sendme from $sender");
34 } elsif ($action eq 'doit') {
35 my $tempfile = "$inn::tmpdir/sendme.$$";
36 open(GREPHIST, "|grephistory -s > $tempfile")
37 or logdie("Cannot run grephistory: $!");
39 print GREPHIST "$_\n";
41 close GREPHIST or logdie("Cannot run grephistory: $!");
43 if (-s $tempfile and $site =~ /^[a-zA-Z0-9.-_]+$/) {
44 open(TEMPFILE, $tempfile) or logdie("Cannot open $tempfile: $!");
45 open(BATCH, ">>$inn::batch/$site.work")
46 or logdie("Cannot open $inn::batch/$site.work: $!");
47 print BATCH $_ while <TEMPFILE>;