ispCP - Board - Support
Log emails - Printable Version

+- ispCP - Board - Support (http://www.isp-control.net/forum)
+-- Forum: ispCP Omega Development Area (/forum-1.html)
+--- Forum: General discussion (/forum-11.html)
+--- Thread: Log emails (/thread-7749.html)



Log emails - morb - 09-04-2009 03:16 AM

Hi there,

How can I log emails sent from mail function on php ?? And know how many mails has certain user sent tought smtp?

Thankz in advance


RE: Log emails - Knut - 09-04-2009 04:00 AM

Hi,

copy this script as /usr/sbin/sendmail-php
Code:
!/usr/bin/perl

# use strict;
use Env;
my $date = `date`;
chomp $date;
open (INFO, ">>/var/log/spam.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";

}
my $mailprog = '/usr/sbin/sendmail';
foreach (@ARGV) {
$arg="$arg" . " $_";
}

open (MAIL,"|$mailprog $arg") || die "cannot open $mailprog: $!n";
while (<STDIN> ) {
print MAIL;
}
close (INFO);
close (MAIL);

then
Code:
chmod +x /usr/sbin/sendmail-php
touch /var/log/spam.log
chmod 777 /var/log/spam.log

change your php.ini for the sites

Code:
; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = /usr/sbin/sendmail-php

maybe restart Apache ... done.

(original by J-B (21.11.2006) @ sysop-forum.de)