Current time: 11-23-2024, 06:19 AM Hello There, Guest! (LoginRegister)


Post Reply 
Log emails
Author Message
morb Offline
Newbie
*

Posts: 6
Joined: Jun 2009
Reputation: 0
Post: #1
Log emails
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
09-04-2009 03:16 AM
Find all posts by this user Quote this message in a reply
Knut Offline
Member
***

Posts: 736
Joined: Nov 2006
Reputation: 10
Post: #2
RE: Log emails
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)
09-04-2009 04:00 AM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)