note 78934 added to function.mail

From: Date: Sat, 03 Nov 2007 00:37:36 +0000
Subject: note 78934 added to function.mail
Groups: php.notes 
Request: Send a blank email to php-notes+get-131958@lists.php.net to get a copy of this message
Tired of idiots and imbeciles who creates unsecure php-code and lets spammers abuse mail()? Try this dirty trick: With auto_prepend, prepend this file: <?php // You need to install pecl-module, runkit. dl("runkit.so"); // We could rename the function, but that currently makes my apache segfault, but this works :-P runkit_function_copy ( "mail","intmail" ); runkit_function_remove( "mail" ); function mail( $to, $subject, $message, $additional_headers = null, $additional_parameters = null ) { $___domain = $_SERVER['SERVER_NAME']; $fp = fopen("/tmp/my_super_mail_logg", "a"); fwrite( $fp, date("d.m.y H:i:s") . " " . $___domain . ": $to / $subject\n"); fclose( $fp ); return intmail( $to, $subject, $message, $additional_headers, $additional_parameters ); } ?> You probably shouldn't log to /tmp, or any other place as the webserver-user, see syslog-functions ;) And of course you can manipulate the different parameters, like adding custom headers to each email (For instance; "X-From-Web: {$_SERVER['SERVER_NAME']}").. ---- Server IP: 62.73.197.23 Probable Submitter: 80.203.251.213 ---- Manual Page -- http://www.php.net/manual/en/function.mail.php Edit -- https://master.php.net/note/edit/78934 Del: integrated -- https://master.php.net/note/delete/78934/integrated Del: useless -- https://master.php.net/note/delete/78934/useless Del: bad code -- https://master.php.net/note/delete/78934/bad+code Del: spam -- https://master.php.net/note/delete/78934/spam Del: non-english -- https://master.php.net/note/delete/78934/non-english Del: in docs -- https://master.php.net/note/delete/78934/in+docs Del: other reasons-- https://master.php.net/note/delete/78934 Reject -- https://master.php.net/note/reject/78934 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#131958) next »