HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Server Operation (http://www.howtoforge.com/forums/forumdisplay.php?f=5)
-   -   How To Log Emails Sent With PHP's mail() Function To Detect Form Spam (http://www.howtoforge.com/forums/showthread.php?t=38025)

princebenin 6th August 2009 19:46

How To Log Emails Sent With PHP's mail() Function To Detect Form Spam
 
Hi,
The script written by Still log the e-mails but not sending them.

http://howtoforge.org/how-to-log-ema...tect-form-spam

falko 7th August 2009 12:59

Any errors in your mail log?

princebenin 8th August 2009 10:23

Thank you Till for the correction.
 
The howto is very useful.

sajo 21st January 2011 20:57

Quote:

Originally Posted by princebenin (Post 200428)
Hi,
The script written by Still log the e-mails but not sending them.

http://howtoforge.org/how-to-log-ema...tect-form-spam

I try to make this script working several times but no luck.
I have same problem, the script is logging but no emails is sent out.
I check mail.log and there is fatal error with sendmail.

PHP Code:

Jan 21 20:54:44 server imapdConnectionip=[::ffff:127.0.0.1]
Jan 21 20:54:44 server imapdLOGINuser=sajoip=[::ffff:127.0.0.1], port=[55615], protocol=IMAP
Jan 21 20
:54:44 server postfix/sendmail[14649]: fatalusagesendmail [options]
Jan 21 20:54:44 server imapdLOGOUTuser=sajoip=[::ffff:127.0.0.1], headers=0body=0rcvd=430sent=327time=


this is my phpsendmail file

PHP Code:

server:/home/damjan# vi /etc/php5/apache2/php.ini
server:/home/damjan# vi /usr/local/bin/phpsendmail
#!/usr/bin/php
<?php

/**
  This script is a sendmail wrapper for php to log calls of the php mail() function.
  Author: Till Brehm, www.ispconfig.org
  (Hopefully) secured by David Goodwin <david @ _palepurple_.co.uk>
*/

$sendmail_bin '/usr/sbin/sendmail';
$logfile '/var/log/mail.form';

//* 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)." \n";
        }
        
$mail .= $line;
}

//* compose the sendmail command
$command 'echo ' escapeshellarg($mail) . ' | '.$sendmail_bin.' -t -i';
for (
$i 1$i $_SERVER['argc']; $i++) {
        
$command .= escapeshellarg($_SERVER['argv'][$i]).' ';
}



//* Write the log
file_put_contents($logfiledate('Y-m-d H:i:s') . ' ' $_ENV['PWD'] . ' ' $loglineFILE_APPEND);
//* Execute the command
return shell_exec($command);
?>

Please, need some help.
Thanks in advance

falko 22nd January 2011 14:49

Does /usr/sbin/sendmail exist? Is the path correct?

sajo 23rd January 2011 19:04

Hello, Falko thanks for help.

Yes path is correct and file is there.

unai 12th February 2011 19:01

Issues sending UTF-8 encoded emails
 
Dear All,

We have had issues sending UTF-8 encoded emails when using this phpsendmail wrapper instead of the normal sendmail method. Basically the contents get all turned into unreadable characters.

Has anyone experienced similar issues? Would there be a way of fixing this?

Thank you so much for the excellent information.

With Best Wishes,
Unai Rodriguez


All times are GMT +2. The time now is 08:22.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.