#!/usr/bin/perl # # Wrapper to sendmail calls from PHP's mail() # # Configure sendmail_path in your php.ini to point to this script, # and touch and chmod 777 /var/log/wrapsendmail.log # # It logs some information about page calling mail(), and after that # calls the real sendmail binary. # # I think this script is public domain. # use Env; my $date = `date`; chomp $date; open (INFO, ">>/var/log/wrapsendmail.log") || die "Failed to open file ::$!"; my $uid = $>; my @info = getpwuid($uid); if ($REMOTE_ADDR) { print INFO "$date - $REMOTE_ADDR ran $SCRIPT_NAME at $SERVER_NAME \n"; } else { print INFO "$date - $PWD - @info\n"; } my $mailprog = '/usr/sbin/sendmail'; foreach (@ARGV) { $arg="$arg" . " $_"; } open (MAIL,"|$mailprog $arg") || die "cannot open $mailprog: $!\n"; while () { print MAIL; } close (INFO); close (MAIL); # EOF