Answer the question
In order to leave comments, you need to log in
How to make a stub for mail on localhost?
Created mail.php file
<?php
$str = date( 'Y-m-d H:i:s' )."\r\n";
$str .= file_get_contents( 'php://stdin' )."\r\n\r\n";
file_put_contents( __DIR__.'/mail_log.txt', $str, FILE_APPEND );
?>
Answer the question
In order to leave comments, you need to log in
Good morning.
I did not find a link to the blog where I found this solution, but here is the script and some description for you.
I use ubuntu, but I think that if you have windows, you can still run this stub. Perhaps tweaking the script a bit.
#!/usr/bin/php
<?php
/* заглушка mail() */
$input = file_get_contents('php://stdin');
preg_match('|^To: (.*)|', $input, $matches);
//$t = tempnam("/home/username/localhost/email", $matches[1]);
//
// более понятно название файла + возможность открывать в почтовой программе
$t = "/home/username/localhost/email/" . $matches[1] . '_' . time() . '.eml';
chmod($t, 0644);
file_put_contents($t, $input);
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question