Created
July 19, 2013 08:34
Revisions
-
Alexandr created this gist
Jul 19, 2013 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,61 @@ <?php //insert into php.ini //sendmail_path = "/usr/local/bin/php /localetc/sendmail_stub/fake.php" $sendMailStubObj = new SendMailStub(); $sendMailStubObj->main(); class SendMailStub { private $_saveEmailsPath = "/home/tobur/mail/"; function main() { //--- get email from the stream ---// $stream_data = ''; $stream_handler = fopen('php://stdin', 'r'); while ($t = fread($stream_handler, 2048)) { if ($t === chr(0)) break; $stream_data .= $t; } fclose($stream_handler); //save to file $fwrite_handler = fopen($this->_generateUniquePath(), 'w'); fwrite($fwrite_handler, $stream_data); fclose($fwrite_handler); } private function _generateUniquePath() { $i = 0; do { $path = $this->_saveEmailsPath . $this->_generateFname($i); $i++; if($i > 100){ break; } } while (file_exists($path) == true); return $path; } private function _generateFname($i = 0) { $parts = array( date('Y-m-d_H-i-s'), ); if ($i > 0) { $parts[] = "_{$i}"; } $parts[] = ".eml"; $fname = implode("", $parts); return $fname; } }