Hi all,
This is how i log sendmail abuse atm.
Please feel free to improve anything
note that ussing a passtrue like this aint the most secure way todo it.
If u know a solution for this, please let me know.
1. Create this file on your server
/usr/local/lib/php/begin.inc.php
add the following:
2. Open your php.ini file and add this:
auto_prepend_file = /usr/local/lib/php/begin.inc.php
sendmail_path = /usr/local/bin/phpsendmail
3. Create the following file and add the code to it
nano /usr/local/bin/phpsendmail
4. chmod and tocuh the following files
chmod +x /usr/local/bin/phpsendmail
touch /var/log/mail.form
chmod 777 /var/log/mail.form
5. restart your webserver
service httpd restart
6. test it
put this script on 1 of your domains and call it from the browser
7. Your done!
cat /var/log/mail.form
If u want all domains to act on this, also set these files
/usr/local/directadmin/data/templates/virtual_host.conf
/usr/local/directadmin/data/templates/virtual_host2.conf
if u use ssl u need to change the secure files to.
change the sendmail path to
/usr/local/bin/phpsendmail
if ur done run
"action=rewrite&value=httpd" >> /usr/local/directadmin/data/task.queue /usr/local/directadmin/dataskq d
This is how i log sendmail abuse atm.
Please feel free to improve anything
note that ussing a passtrue like this aint the most secure way todo it.
If u know a solution for this, please let me know.
1. Create this file on your server
/usr/local/lib/php/begin.inc.php
add the following:
Code:
<?php
putenv("PATH_INFO=". $_SERVER["PATH_INFO"]);
putenv("SCRIPT_NAME=". $_SERVER["SCRIPT_NAME"]);
putenv("SCRIPT_FILENAME=". $_SERVER["SCRIPT_FILENAME"]);
putenv("REMOTE_ADDR=". $_SERVER["REMOTE_ADDR"]);
putenv("HTTP_HOST=". $_SERVER["HTTP_HOST"]);
?>
2. Open your php.ini file and add this:
auto_prepend_file = /usr/local/lib/php/begin.inc.php
sendmail_path = /usr/local/bin/phpsendmail
3. Create the following file and add the code to it
nano /usr/local/bin/phpsendmail
Code:
#!/usr/local/bin/php
<?php
$sendmail_bin = '/usr/sbin/sendmail';
$logfile = '/var/log/mail_php.log';
//* Get the email content
$logline = '';
$pointer = fopen('php://stdin', 'r');
while ($line = fgets($pointer)) {
if(preg_match('/^to:/i', $line) || preg_match('/^from:/i', $line)) {
$logline .= trim($line).' ';
}
$mail .= $line;
}
//* compose the sendmail command
$command = 'echo ' . escapeshellarg($mail) . ' | '.$sendmail_bin.' ';
for ($i = 1; $i < $_SERVER['argc']; $i++) {
$command .= escapeshellarg($_SERVER['argv'][$i]).' ';
}
file_put_contents($logfile, date('Y-m-d H:i:s') . ' ' . $_ENV['PWD'] . ' ' . $_ENV['PATH_INFO'] . ' ' . $_ENV['SCRIPT_NAME'] . ' ' .
$_ENV['SCRIPT_FILENAME'] . ' ' . $_ENV['REMOTE_ADDR'] . ' ' . $_ENV['HTTP_HOST'] . '' . $logline . '\n',
FILE_APPEND);
//* Execute the command
return shell_exec($command);
?>
4. chmod and tocuh the following files
chmod +x /usr/local/bin/phpsendmail
touch /var/log/mail.form
chmod 777 /var/log/mail.form
5. restart your webserver
service httpd restart
6. test it
put this script on 1 of your domains and call it from the browser
Code:
<?php
mail('[email protected]','This is a test message subject','This is a test message body');
echo 'Mail sent.';
?>
7. Your done!
cat /var/log/mail.form
If u want all domains to act on this, also set these files
/usr/local/directadmin/data/templates/virtual_host.conf
/usr/local/directadmin/data/templates/virtual_host2.conf
if u use ssl u need to change the secure files to.
change the sendmail path to
/usr/local/bin/phpsendmail
if ur done run
"action=rewrite&value=httpd" >> /usr/local/directadmin/data/task.queue /usr/local/directadmin/dataskq d
Last edited: