note 78934 deleted from function.mail by aharvey

From: Date: Mon, 21 Jan 2013 01:22:56 +0000
Subject: note 78934 deleted from function.mail by aharvey
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-193282@lists.php.net to get a copy of this message
Note Submitter: hn at nesland dot net ---- 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']}")..

« previous php.notes (#193282) next »