t

Tag Archive 'sendmail'

2009 Aug 28 2009

keep a record of mail sent to PHP's mail function

Published by under linux


PHP mail () function defined by default in the sent e-mails sent through the sendmail software. LOG settings, which also improves the level of Sendmail was sent by which user can not find the file or. Especially if you have a machine that serves as a provider of web resources on which user you are sending junk e-mail is difficult to detect using. Used methods to php sendmail mail server that comes to mind as a bridge between the undertaking and also to add a software that keeps records. As follows;

vi /usr/sbin/sendmail.spamkontrol

into 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 for the php.ini file: 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'

You can also enter this value for each VirtualHost definition. After restarting Apache in / var / log / spam_log file will issue the output file, such as sample records.

[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 -

If the log file size grows, log rotation, so the / 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]

One response so far

Tags

awk axis bash bat batch files, big with the Open db2 delete autorun disk with the disk rotor dreambox du edg-nemesis find hidden mp3 ibm LMS WCL ibm ibm wcs Learning Management System lmsapi LMSRosterAPI maildir maildir you mp3 mysql nabilo open with passwd password remove all remove space in file rename reset reset password reset root root Skybox ssh ssh push vi vim vimproved workplace learning collaborative workplace

Search