Log instead of PHP mail()

Months ago I was looking for a solution to log outgoing mails instead of sending them. This week I found a solution mentioned in Sean's PHP-Related Weblog.

For me only this part was interesting:

PHP:

<?php

$stdin 
fopen('php://stdin''r');
$in '';
while (!
feof($stdin)) {
    
$in .= fread($stdin1024); // read 1kB at a time
}

?>

It allows you to read from stdin and grab the data that usually would be sent by mail.

To get this to work on Windows I needed to create a batch file that calls PHP with the PHP file as parameter:

c:\apache\php\php.exe -q "c:\www\maillogger.php"

And finally the path to the batch file needs to be set as sendmail_path in php.ini.

sendmail_path = "d:\www\maillogger\maillogger.bat"


Back
Add to: del.icio.us Yahoo! MyWeb StumbleUpon Furl Blinklist Spurl Technorati Digg reddit Rojo Netscape Newsvine Add This!

RSS Feed   Atom Feed

PHP Scripts
Website Content
Resources