Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Server Operation

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 6th August 2009, 19:46
princebenin princebenin is offline
Junior Member
 
Join Date: Nov 2006
Posts: 16
Thanks: 3
Thanked 1 Time in 1 Post
Default 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
Reply With Quote
Sponsored Links
  #2  
Old 7th August 2009, 12:59
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,741 Times in 2,575 Posts
Default

Any errors in your mail log?
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
The Following User Says Thank You to falko For This Useful Post:
princebenin (8th August 2009)
  #3  
Old 8th August 2009, 10:23
princebenin princebenin is offline
Junior Member
 
Join Date: Nov 2006
Posts: 16
Thanks: 3
Thanked 1 Time in 1 Post
Default Thank you Till for the correction.

The howto is very useful.
Reply With Quote
  #4  
Old 21st January 2011, 20:57
sajo sajo is offline
Member
 
Join Date: Oct 2006
Posts: 42
Thanks: 4
Thanked 1 Time in 1 Post
Default

Quote:
Originally Posted by princebenin View Post
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
Reply With Quote
  #5  
Old 22nd January 2011, 14:49
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,741 Times in 2,575 Posts
Default

Does /usr/sbin/sendmail exist? Is the path correct?
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #6  
Old 23rd January 2011, 19:04
sajo sajo is offline
Member
 
Join Date: Oct 2006
Posts: 42
Thanks: 4
Thanked 1 Time in 1 Post
Default

Hello, Falko thanks for help.

Yes path is correct and file is there.
Reply With Quote
  #7  
Old 12th February 2011, 19:01
unai unai is offline
Junior Member
 
Join Date: Feb 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
 
Default 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
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail server using Postfix, Dovecot, Mysql... Postfix virtual maps doesn't work?? tarasbuljba HOWTO-Related Questions 33 28th May 2010 14:33
just the last step...and it works. Postfix...need help config. ubuntusr Installation/Configuration 1 5th January 2009 09:50
Mail System Error - Returned Mail tristanlee85 General 16 16th March 2008 09:40
Core 4: Error Messages on Fresh Install re CTX/SSL jjw Installation/Configuration 30 6th September 2006 12:16
Can not recieve mail with de virtual mail adress Mounir Installation/Configuration 9 24th July 2006 23:16


All times are GMT +2. The time now is 06:30.


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