Tag: spammer logging
keep a record of mail sent from php mail function
by admin on Aug.28, 2009, under linux
php mail () function defined by default in the sent e-mails sent through the sendmail software. Sendmail settings, which also raises the level of the LOG file, or sent by which user can not find. Especially if you have a web provider that serves as a machine which user is sending junk e-mail using your resources is difficult to identify. Yöntemse php sendmail mail server that comes to mind to serve as a bridge between the undertaking and also to add a software that keeps recording. As follows;
vi /usr/sbin/sendmail.spamkontrol
in saying
#! / Usr / bin / perl
# Use strict;
use Env;
my $ date = `date`;
chomp $ date;
open (INFO, ">> / var / log / spam_log") | | die "File could not boot ::$!";
my $ uid = $>;
my @ info = getpwuid ($ uid);
if ($ REMOTE_ADDR) {
print INFO "$ date - $ REMOTE_ADDR ran $ SCRIPT_NAME at $ SERVER_NAME n \ n";
print '\ n';}
else {print INFO "$ date - $ PWD - @ info \ n";
print '\ n';}
my $ mailprog = '/ usr / sbin / sendmail';
foreach (@ ARGV) {
$ Arg = "$ arg". "$ _";
}open (MAIL, "| $ mailprog $ arg") | | die "can not open $ mailprog: $! n";
while () {
print MAIL;
}
close (INFO);
close (MAIL);
After you save the file;
chmod +x /usr/sbin/sendmail.spamkontrol
touch /var/log/spam_log
chmod 0777 /var/log/spam_log
After giving the necessary powers in the form of a new recipe, the php.ini file that sendmail in the / usr / sbin / sendmail.spamkontrol can enter the following as the definition of Virtual Host in Apache or you can enter a description.
php_admin_value sendmail_path '/usr/sbin/sendmail.spamkontrol'
This value can also enter the definition of each VirtualHost. After restarting Apache in / var / log / spam_log file as the output file will issue the sample record.
[root@immortal ~]# tail /var/log/spam_log
Fri Aug 28 15:37:20 EEST 2009 - /home/testuser1 -
Fri Aug 28 15:45:01 EEST 2009 - /home/testuser2 -
Fri Aug 28 15:53:30 EEST 2009 - /home/testuser1 -
Fri Aug 28 15:57:43 EEST 2009 - /home/testuser1 -
Fri Aug 28 15:58:47 EEST 2009 - /home/testuser2 -
Fri Aug 28 16:21:21 EEST 2009 - /home/testuser2 -
The size of the log file grows to the log rotation to / etc / logrotate.conf file, add the following.
# SPAM LOG rotation
/var/log/spam_log {
monthly
create 0777 root root
rotate 1
}
[Mattf and ramprage'e thanks]
