note 59478 added to ref.mail

From: Date: Thu, 08 Dec 2005 04:29:35 +0000
Subject: note 59478 added to ref.mail
Groups: php.notes 
Request: Send a blank email to php-notes+get-99724@lists.php.net to get a copy of this message
I just thought this would be useful for someone. It's one thing to write your mail forms so they don't support spam via header injection. It's quite another to run a hosting operation with hundreds of web sites that are controlled by different webmasters and customers that do not want to pay to have thier sites fixed. In fact it's very difficult to identify all the buggy sites. As a result, I came up with this little sendmail wrapper. I made this as a cli script and used it as a replacement for sendmail in the php.ini file. Since our web servers have no reason to send BCC and CC Header, this script renames them so they don't work. You would also need to write a script to clean up the temporary files. This script could save messages that were spamming attempts so you can study them later. It would just look for the replacement headers to determine if it was a spamming attempt. <?php $tmpfile = "/tmp/" . uniqid('') . ".mail"; $fp = fopen($tmpfile,"w"); fwrite($fp,"x-wls-cc-filter: On\n"); while($line = fgets(STDIN)) { $line = ereg_replace("^bcc:","x-wlsspam-bcc:",$line); $line = ereg_replace("^cc:","x-wlsspam-cc:",$line); fwrite($fp,$line); } fclose($fp); $cmd = '/usr/sbin/sendmail '; for($i = 1 ; $i < $argc; $i++) { $cmd .= $argv[$i]; $cmd .= ' '; } $cmd .= "<$tmpfile"; system($cmd); ?> ---- Manual Page -- http://www.php.net/manual/en/ref.mail.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+59478 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59478&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59478&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59478&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59478&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59478&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59478&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59478&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+59478&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#99724) next »